Bonjour à vous
Jusqu'à ce jour j'ai cru que la boucle do until avait deux syntaxes
Do until condition
code
loop
ou
do
code
loop until condition
La seule différence que je voyais était que dans le second cas, la boucle se faisait au moins une fois.
Or dans un bout de vba je me suis aperçu que la différence semble aller au-delà.
mon code :
Sub truc()
Dim pl As Range
Set pl = Range("a1:h34")
h = 0
For i = 1 To pl.Count
pl(i) = Int(Rnd() * 1000)
Next i
b = pl.Value
For i = 1 To UBound(b, 1)
For j = 1 To UBound(b, 2)
Rnd (b(i, j))
If b(i, j) Mod 3 = 1 Then
With Cells(i, j)
.Interior.ColorIndex = 34
.Font.ColorIndex = 3
End With
End If
Next j
Next i
Range("a1").CurrentRegion = b
End Sub
Sub CaMarche()
For Each c In Range("a1:h34")
Do Until c.Interior.ColorIndex = 34
truc
h = h + 1
Loop
Next
MsgBox h
End Sub
Sub CaNeMarchePas()
For Each c In Range("a1:h34")
Do
truc
h = h + 1
Loop Until c.Interior.ColorIndex = 34
Next
MsgBox h
End Sub
Merci pour votre attention. Je vous joins le classeur.