Tim Hanson
Member
Hello,
I got the code below from this thread written by @Marc L
http://forum.chandoo.org/threads/multiple-columns-lookup.33813/
It the best matching code I have found, its works great for my needs!
I often need to find all the rows that don't match as well as the matching rows
Is there a way to alter the code so that it paste the not matched rows to sheet ZZ also
I have tried to figure this out but I have failed
Thanks
I got the code below from this thread written by @Marc L
http://forum.chandoo.org/threads/multiple-columns-lookup.33813/
It the best matching code I have found, its works great for my needs!
I often need to find all the rows that don't match as well as the matching rows
Is there a way to alter the code so that it paste the not matched rows to sheet ZZ also
I have tried to figure this out but I have failed
Thanks
Code:
Sub Demo()
Const DL = "¤"
Dim Dict As Object, Rg As Range, C, R&, K$, L&
Set Dict = CreateObject("Scripting.Dictionary")
Set Rg = ThisWorkbook.Sheets("X").UsedRange.Rows
C = [{3,4,5}]
For R = 2 To Rg.Count
Dict(Join(Application.Index(Rg(R), , C), DL)) = R
Next
ThisWorkbook.Sheets("Z").UsedRange.Offset(1).Clear
With ThisWorkbook.Sheets("y").UsedRange.Rows
.Interior.ColorIndex = xlNone
Application.ScreenUpdating = False
C = [{5,1,4}]
L = 1
For R = 2 To .Count
K = Join(Application.Index(.Item(R), , C), DL)
If Dict.Exists(K) Then
Rg(Dict(K)).Copy ThisWorkbook.Sheets("Z").Cells(Dict(K), 1)
Else
.Item(R).Interior.ColorIndex = 36
End If
Next
Application.ScreenUpdating = True
End With
Dict.RemoveAll
Set Dict = Nothing: Set Rg = Nothing
End Sub