Sub kleuren()
Dim iSgn
With Range("A5:w21") 'your range
For i = 1 To .Rows.Count 'loop through the rows
ptr = 0 'reset counter
For j = 2 To .Columns.Count 'loop through the columns
iSgn = Sgn(.Cells(i, j) - .Cells(i, j - 1)) 'actual direction (down=-1, equal=0,up=+1)
ptr = -ptr * ((iSgn = Sgn(ptr)) Or (iSgn = 0)) + iSgn 'counter direction
maincolor = Application.Min(255, 255 - Abs(ptr) * 5) 'maincolor for green or red in RGB
auxcolor = Application.Max(1, 200 - Abs(ptr) * 20) 'the 2 other colors in RGB
Select Case ptr
Case -1 To 1: .Cells(i, j).Interior.ColorIndex = xlNone
Case Is < -1: .Cells(i, j).Interior.Color = RGB(maincolor, auxcolor, auxcolor)
Case Else: .Cells(i, j).Interior.Color = RGB(auxcolor, maincolor, auxcolor)
End Select
Next
Next
End With
End Sub