Correction de VBA
Hello, les gens !
Bon sans vous mentir les connaissances en VBA j'en ai pas je me suis lancer dans un projet sans même pouvoir le réaliser donc c'est pour cela que je viens vous demander de l'aide car même en cherchant sur internet des informations je nage et j'ai l'impression de ne pas avancer donc si vous pouvez jeter un petit coup d’œil à mon code ça serait super cool.
Cdlt Antoine
Sub aa()
Dim i As Integer, j As Integer
Application.ScreenUpdating = False
Dim factureSheet As Worksheet
Dim commandeSheet As Worksheet
Set factureSheet = Application.Workbooks.Item("Antoine 1.xlsx").Worksheets.Item("feuil1")
Set commandeSheet = Application.Workbooks.Item("Antoine 2.xlsx").Worksheets.Item("feuil3")
Dim commandeTrouve As Boolean
For i = 2 To factureSheet.Range("A1048576").End(xlUp).Row
Let commandeTrouve = False
While j = 2 To commandeSheet.Range("C1048576").End(xlUp).Row
If factureSheet.Cells(i, 1) = commandeSheet.Cells(j, 3) And factureSheet.Cells(i, 2) = commandeSheet.Cells(j, 4) Then
Range(factureSheet.Cells(i, 1), factureSheet.Cells(i, 2)).Font.ColorIndex = 4 ' vert
Wend
End If
Next j
While i=2 To factureSheet.Range(factureSheet.Cells(i, 1), factureSheet.Cells(i, 2)).Font.ColorIndex = 3 ' rouge
Next i
Application.ScreenUpdating = True
End SubBonjour
Si tu donnais l'explication de ce que tu veux faire avec cette macro
D'après ce que j'ai compris
Tu vérifies que pour chaque facture il y a une commande et dans ce cas tu colorises la facture en vert, sinon tu la colorise en rouge
Exact ou me suis planté ?
Vois ce code
Sub aa()
Dim I As Long, J As Long
Dim factureSheet As Worksheet
Dim commandeSheet As Worksheet
Dim commandeTrouve As Boolean
Application.ScreenUpdating = False
Set factureSheet = Workbooks("Antoine 1.xlsx").Worksheets("feuil1")
Set commandeSheet = Workbooks("Antoine 2.xlsx").Worksheets("feuil3")
For I = 2 To factureSheet.Range("A1048576").End(xlUp).Row
commandeTrouve = False
For J = 2 To commandeSheet.Range("C1048576").End(xlUp).Row
If factureSheet.Cells(I, 1) = commandeSheet.Cells(J, 3) And factureSheet.Cells(I, 2) = commandeSheet.Cells(J, 4) Then
commandeTrouve = True
factureSheet.Range(factureSheet.Cells(I, 1), factureSheet.Cells(I, 2)).Font.ColorIndex = 4 ' vert
Exit For
End If
Next J
If commandeTrouve = False Then
factureSheet.Range(factureSheet.Cells(I, 1), factureSheet.Cells(I, 2)).Font.ColorIndex = 3 ' rouge
End If
Next I
Application.ScreenUpdating = True
End SubOui c'est parfait je savais que quelqu'un allait trouvé sans même donner des explications =) Je t'en remercie