Bonjour,
Voilà, en tant que débutant, j'utilise VBA pour me faciliter la tâche dans l'exploitation de fichier.
J'ai mis en place une macro qui fonctionne très bien mais dont un bout de code pourrait être optimiser mais je ne sais pas comment.

Je vous adresse donc ce bout pour avoir vos retours et me permettre de me perfectionner dans la logique VBA :-)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
sub Formula ()
 
Dim DerLig As Long
 
Workbooks("TABLEAU_I.xlsx").Activate
Sheets("BDD_PT").Activate
 
Range("a1").Select
DerLig = Range(Selection, Selection.End(xlDown)).Count
 
Range("b2").Formula = "=IF(RC[1]>1,1,0)"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:b" & DerLig)
 
Range("l2").Formula = "=YEAR(RC[2])"
Range("l2").Select
Selection.AutoFill Destination:=Range("l2:l" & DerLig)
 
Range("m2").Formula = "=WEEKNUM(RC[1])"
Range("m2").Select
Selection.AutoFill Destination:=Range("m2:m" & DerLig)
 
Range("q2").Formula = "=YEAR(RC[2])"
Range("q2").Select
Selection.AutoFill Destination:=Range("q2:q" & DerLig)
 
Range("r2").Formula = "=WEEKNUM(RC[1])"
Range("r2").Select
Selection.AutoFill Destination:=Range("r2:r" & DerLig)
 
Range("x2").Formula = "=YEAR(RC[2])"
Range("x2").Select
Selection.AutoFill Destination:=Range("x2:x" & DerLig)
 
Range("y2").Formula = "=WEEKNUM(RC[1])"
Range("y2").Select
Selection.AutoFill Destination:=Range("y2:y" & DerLig)
 
Range("ah2").Formula = "=IF(RC[-1]>"""",1,0)"
Range("ah2").Select
Selection.AutoFill Destination:=Range("ah2:ah" & DerLig)
 
Range("an2").Formula = "=+RC[-38]-RC[-6]"
Range("an2").Select
Selection.AutoFill Destination:=Range("an2:an" & DerLig)
 
Range("ao2").Formula = "=+IF(RC[-1]>0,RC[-2],0)"
Range("ao2").Select
Selection.AutoFill Destination:=Range("ao2:ao" & DerLig)
 
Range("ap2").Formula = "=+IF(OR(RC[-15]=0,RC[-16]=0),"""",RC[-15]-RC[-16])"
Range("ap2").Select
Selection.AutoFill Destination:=Range("ap2:ap" & DerLig)
 
Range("aq2").Formula = "=+IF(OR(RC[-14]=0,RC[-16]=0),"""",RC[-14]-RC[-16])"
Range("aq2").Select
Selection.AutoFill Destination:=Range("aq2:aq" & DerLig)
 
Range("ar2").Formula = "=+IF(AND(RC[-33]<>""EN COURS"",OR(MID(LEFT(RC[-37]),1,1)=""E"",MID(LEFT(RC[-37],5),1,5)=""JEU I""),TODAY()>RC[-23]-7),""URGENT"","""")"
Range("ar2").Select
Selection.AutoFill Destination:=Range("ar2:ar" & DerLig)
 
End Sub
La plupart des avis expliquent que l'utilisation abusive de select ralentit le code...

Merci pour vos avis.