• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Alter matching Macro to also find non matching rows

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

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
 

Attachments

  • Mathch.xlsm
    49.7 KB · Views: 1
Hi !

As it is a case of wild cross posting, read this !

Post here a link for every other forum where you created same thread …
 
I have posted very different Question about how to alter this code to work in a way I need

I did this so as to not pester a single forum
 
Back
Top