Identifier les nombres opposés
Bonjour à tous,
Je suis débutant sur VBA.
J'ai trouvé une macro qui me convient totalement. Elle permet d'identifier les nombres opposés d'une liste.
J'aimerai comprendre la macro pour pouvoir aussi la modifier à ma convenance. Est-ce que quelqu'un pourrait me l'explquer ligne par ligne ? (avec une sorte de lisez)
Merci d'avance.
La voici ci-dessous :
Code:
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
| Sub test()
Dim i%, j%
k = Range("H1").End(4).Row
For i = 2 To k - 1
Y = False
If Cells(i, 9) = 0 Then
For j = i + 1 To k
If Cells(i, 8) + Cells(j, 8) = 0 Then
If controle(i, j) Then
Cells(i, 9) = x + 1
Cells(j, 9) = x + 1
x = x + 1
Y = True
End If
End If
If Y Then Exit For
Next j
End If
Next i
End Sub
Function controle(i%, j%) As Boolean
controle = (Cells(i, 6) = Cells(j, 6)) And Cells(j, 9) = 0
End Function |