
Originally Posted by
PeterJohns
Column a is unique and column J has multiples of column a (though not all column a values match). I need to match and colour each corresponding value.
...
Some of the spreadsheets i have to check are in excess of 100K rows. Ouch
Peter,
If this quote does indeed accurately describe your dataset, and you do have 100K+ rows, and want to bypass rows with 100 in col D, then you may like to try the following
Sub color_matches_x()
Dim rsa&, rsj&, u&
Dim a, j, d
Dim adra As String, adrj As String
Dim b As Object, c As Object
Set b = CreateObject("scripting.dictionary")
Set c = CreateObject("scripting.dictionary")
rsa = Cells(Rows.Count, 1).End(3).Row
rsj = Cells(Rows.Count, "j").End(3).Row
a = Range("A1:A" & rsa)
j = Range("J1:J" & rsj)
d = Range("D:D").Value
For u = 2 To rsa
If (d(u, 1) = 100) * (Len(a(u, 1)) > 0) Then b(a(u, 1)) = True
Next u
For u = 2 To rsj
If (d(u, 1) = 100) * (Len(j(u, 1)) > 0) Then
c(j(u, 1)) = True
If b(j(u, 1)) Then
If Len(adrj & ",J" & u) > 254 Then
Range(Mid(adrj, 2)).Interior.Color = vbYellow
adrj = ",J" & u
Else
adrj = adrj & ",J" & u
End If
End If
End If
Next u
For u = 2 To rsa
If (d(u, 1) = 100) * (Len(a(u, 1)) > 0) Then
If c(a(u, 1)) Then
If Len(adra & ",A" & u) > 254 Then
Range(Mid(adra, 2)).Interior.Color = vbYellow
adra = ",A" & u
Else
adra = adra & ",A" & u
End If
End If
End If
Next u
Range(Mid(adra, 2)).Interior.Color = vbYellow
Range(Mid(adrj, 2)).Interior.Color = vbYellow
End Sub
Bookmarks