Bonjour,
Le code apporté dans la solution fonctionne très bien. Toutefois, j'aurais peut-être à le modifier prochainement, d'ou l'importance que je comprenne comment il fonctionne.
J'ai fais pas mal de VBA il y a 3 ans et je dois avouer que me remettre dedans est plus compliqué que je ne l'aurais pensé. C'est pourquoi, j'aimerais savoir si quelqu'un ici pouvait m'expliquer cette partie du code :
For Each c In plage1
If Left(c, 7) <> "" Then d1(Left(c.Value, 7)) = d1(Left(c.Value, 7)) + 1
Next c
For Each c In plage2
If c <> "" Then d2(c.Value) = d2(c.Value) + 1
If d1.exists(Left(c.Value, 7)) Or c = "" Then
c.Interior.ColorIndex = xlNone
Else
c.Interior.ColorIndex = 3
End If
Next c
For Each c In plage1
If d2.exists(c.Value) Or c = "" Then c.Interior.ColorIndex = xlNone
If d1(Left(c.Value, 7)) > 1 Or c = "" Then
c.Interior.ColorIndex = xlNone
Else
c.Interior.ColorIndex = 3
End If
Next c
For Each c In plage2
If d2(c.Value) > 1 Then c.Interior.ColorIndex = xlNone
Next c
End Sub
1) Je comprends l'utilisation de la boucle dans ce cas présent, mais j'ai de la peine avec les arguments.
"For each c in plage 1"... Dans ce cas, à quoi correspond le "c"? J'ai cherché si la variable avait été déclaré plus haut mais ce n'était pas le cas, donc à quoi correspond ce "c"?
2)" If Left(c, 7) <> "" Then d1(Left(c.Value, 7)) = d1(Left(c.Value, 7)) + 1 "
Ici, si je comprends bien cela revient à faire une comparaison "Gauche, 7 premiers caractères". Ensuite après le "<>" je ne comprends pas l'utilisation du "". Ensuite, je ne comprends pas cette partie: Then d1(Left(c.Value, 7)) = d1(Left(c.Value, 7))
3) Pareil pour celle-ci "If c <> "" Then d2(c.Value) = d2(c.Value) + 1
If d1.exists(Left(c.Value, 7)) Or c = "" Then"
4) For Each c In plage2
If d2(c.Value) > 1 Then c.Interior.ColorIndex = xlNone
Et celle ci non plus ! Comme vous pouvez le constater, j'ai de la peine avec les boucles !
Merci à ceux qui prendront le temps de m'aider à y voir plus clair,
bon dimanche.