L'indice n'appartient pas à la selection

Bon j'ai quasi fini mon code sauf que celui-ci ne trouve pas les bonnes feuilles

Car je suis dans le même workbook y a juste les feuilles qui changent.

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").Worksheets.Item("Module 1")

Set commandeSheet = Application.Workbooks.Item("Antoine 1.xlsx").Worksheets.Item("Module 2")

Dim commandeTrouve As Boolean

For i = 2 To factureSheet.Range("A1048576").End(xlUp).Row

Let commandeTrouve = False

j = 2

While Not commandeTrouve And j < commandeSheet.Range("A1048576").End(xlUp).Row

If factureSheet.Cells(i, 1) = commandeSheet.Cells(j, 1) And factureSheet.Cells(i, 2) = commandeSheet.Cells(j, 2) Then

factureSheet.Range(factureSheet.Cells(i, 1), factureSheet.Cells(i, 2)).Font.ColorIndex = 4 ' vert

commandeTrouve = True

End If

j = j + 1

Wend

If Not commandeTrouve Then

factureSheet.Range(factureSheet.Cells(i, 1), factureSheet.Cells(i, 2)).Font.ColorIndex = 3 ' rouge

End If

Next i

Application.ScreenUpdating = True

End Sub

Merci à tous

Antoine

Bonjour,

Set factureSheet = Application.Workbooks.Item("Antoine 1.xlsx").Worksheets.Item("Module 1")

A+

Merci petit oubli qui me faisait tourner en rond

Rechercher des sujets similaires à "indice appartient pas selection"