I'm new to VBA and have tried the below which doesn't work. Could you help me fix it. I'm trying to make each cell have a different RGB colour based on it's value:
Sub ColorCells()
Dim rwIndex As Integer
Dim colIndex As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
For rwIndex = 1 To 1000
For colIndex = 1 To 1000
r = Cells(rwIndex, colIndex).Value Mod 256
g = Cells(rwIndex, colIndex).Value \ 256 Mod 256
b = Cells(rwIndex, colIndex).Value \ 65536 Mod 256
Cells(rwIndex, colIndex).Interior.ColorIndex = RGB(r, g, b)
Next colIndex
Next rwIndex
End Sub