Sub Main()
Dim r As Range, c As Range, cc As Range
Dim i As Integer, a, b, d
'Change range to suit.
Set r = Range("A2", Cells(Rows.Count, "A").End(xlUp)).Resize(, 7)
'Colors, change to suit.
a = Array(8421504, 15849925, 11851260, 5296274, 12611584, 65535, 10498160)
For Each c In r.Rows
b = UniqueArrayByDict(c.Value)
'd = WorksheetFunction.Transpose(WorksheetFunction.Transpose(b))
For i = 1 To c.Cells.Count
c.Cells(, i).Interior.Color = a(PosInArray(c.Cells(, i).Value, b))
Next i
Next c
End Sub
Function UniqueArrayByDict(Array1d As Variant, Optional compareMethod As Integer = 0) As Variant
Dim dic As Object 'Late Binding method - Requires no Reference
Set dic = CreateObject("Scripting.Dictionary") 'Late or Early Binding method
'Dim dic As Dictionary 'Early Binding method
'Set dic = New Dictionary 'Early Binding Method
Dim e As Variant
dic.CompareMode = compareMethod
'BinaryCompare=0
'TextCompare=1
'DatabaseCompare=2
For Each e In Array1d
If Not dic.Exists(e) Then dic.Add e, Nothing
Next e
UniqueArrayByDict = dic.Keys
End Function
'If array is 0 based, 1 is returned if aValue matches anArray(0).
Function PosInArray(aValue, anArray)
Dim pos As Long, i As Long
On Error Resume Next
pos = -1
For i = LBound(anArray) To UBound(anArray)
If anArray(i) = aValue Then
pos = i
Exit For
End If
Next i
'pos = WorksheetFunction.Match(CStr(aValue), anArray, 0)
PosInArray = pos
End Function