artkitthana
New member
That is, if any set of numbers doesn't match any other box. So let it be white like before?
What I want
What I want
Sub Test0()
Dim rall As Range, r As Range, strVal As String
Dim d As Object, x As Long
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
x = 100000
With Worksheets(1)
Set rall = .Range("E2:E1000,H2:H1000,K2:K1000,N2:N1000,Q2:Q1000,T2:T1000,W2:W1000,Z2:Z1000,AC2:AC1000")
rall.Interior.Color = xlNone
For Each r In rall
If Not IsEmpty(r.Value) Then
strVal = Sort0(Format(r.Value, "000")) ' Ensure the value is treated as a string with leading zeros
If Not d.Exists(strVal) Then
d.Add key:=strVal, Item:=x
r.Interior.Color = x
x = x + 20000
Else
r.Interior.Color = d.Item(strVal)
End If
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
Function Sort0(v As String) As String
Dim arr() As String
Dim i As Integer, j As Integer
Dim tmp As String
' Convert the string to an array of single characters
ReDim arr(Len(v) - 1)
For i = 1 To Len(v)
arr(i - 1) = Mid(v, i, 1)
Next i
' Sort the array of characters
For i = LBound(arr) To UBound(arr) - 1
For j = i + 1 To UBound(arr)
If arr(i) > arr(j) Then
tmp = arr(i)
arr(i) = arr(j)
arr(j) = tmp
End If
Next j
Next i
' Join the sorted array back into a string
Sort0 = Join(arr, "")
End Function