[COLOR="DarkSlateGray"]Sub tata()
Dim ol As Integer, oc As Integer, i As Long, k As Integer, x As Long, y As Long
[COLOR="SeaGreen"]'
'Choix des couleurs[/COLOR]
Range(Cells(1, 1), Cells(256, 256)).Interior.Color = 26367
y = Cells(1, 1).Interior.Color
Range(Cells(2, 2), Cells(255, 255)).Interior.ColorIndex = 4 [COLOR="SeaGreen"]'couleur de fond[/COLOR]
x = Cells(2, 2).Interior.Color
[COLOR="SeaGreen"]'[/COLOR]
For i = 1 To 6 [COLOR="SeaGreen"]'nombre d'itérations (ou de "fourmis"...)[/COLOR]
Cells(128, 128).Select [COLOR="SeaGreen"]'localisation du départ[/COLOR]
ol = -1: oc = 0 [COLOR="SeaGreen"]'direction initiale (vers le haut)[/COLOR]
[COLOR="SeaGreen"]'----- Corps du programme -----[/COLOR]
Do
With Selection
k = 1 + 2 * (.Interior.Color = x)
If ol Then oc = -k * ol: ol = 0 Else ol = k * oc: oc = 0
.Interior.Color = (x + y + k * (x - y)) / 2
.Offset(ol, oc).Select
End With
With Selection: k = (.Row > 1) And (.Row < 256) And (.Column > 1) And (.Column < 256): End With
Loop While k
[COLOR="SeaGreen"]'----- ------------------ -----[/COLOR]
Next i
End Sub[/COLOR]