This is an extract of some code you can also find on the ExcelVBA site.
To determine the color index just use your recorder and add some colors you
would like to use.
With Range("A1")
nr = Range(.Cells(1, 1), .End(xlDown)).Rows.Count
nc = Range(.Cells(1, 1), .End(xlToRight)).Columns.Count
For r = 1 To nr
For c = 1 To nc
If .Cells(r, c).Interior.ColorIndex = ?? Then
ElseIf .Cells(r, c).Interior.ColorIndex = ?? Then
End If
Next c
Next r
End With