Highlight table rows with matches in another table

Samson92

New Member
Joined
May 27, 2019
Messages
18
Hi,

I have a workbook with 2 sheets, Old and New. Every so often I want to compare sets of data based on values in 2 columns, and if they match, highlight the entire row. The tables are laid out the same;
Column A (Client) - Column B - Column C - Column D (Preparer) - Column E - Column F - Column G - Column H

What I want to do, is see which clients are still on the new list. This is done by seeing if the Client Name (Column A) and the Preparer (Column D) from the New data is still on the Old data, and if so, highlight the row on the Old tab.

I've been trying using conditional formatting, but it's mostly looking for other columns too, which need to be there, but just not helpful for this. Thanks.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi Samson92,

Try this:

Code:
Option Explicit
Sub Macro1()

    Dim wsNew As Worksheet
    Dim wsOld As Worksheet
    Dim rngMyCell_New As Range, rngMyRange_New As Range
    Dim rngMyCell_Old As Range, rngMyRange_Old As Range
    Dim strMyKey As String
    
    Application.ScreenUpdating = False
    
    Set wsNew = ThisWorkbook.Sheets("New")
    Set wsOld = ThisWorkbook.Sheets("Old")
    
    For Each rngMyCell_New In wsNew.Range("A2:A" & wsNew.Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row)
        If Len(wsNew.Range("A" & rngMyCell_New.Row)) > 0 And Len(wsNew.Range("D" & rngMyCell_New.Row)) > 0 Then
            strMyKey = StrConv(wsNew.Range("A" & rngMyCell_New.Row), vbUpperCase) & StrConv(wsNew.Range("D" & rngMyCell_New.Row), vbUpperCase)
            For Each rngMyCell_Old In wsOld.Range("A2:A" & wsOld.Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row)
                If strMyKey = StrConv(wsOld.Range("A" & rngMyCell_Old.Row), vbUpperCase) & StrConv(wsOld.Range("D" & rngMyCell_Old.Row), vbUpperCase) Then
                    wsOld.Range("A" & rngMyCell_Old.Row & ":H" & rngMyCell_Old.Row).Interior.Color = RGB(0, 255, 0) 'Colour the matching row(s) green. Change to suit.
                End If
            Next rngMyCell_Old
        End If
    Next rngMyCell_New
    
    Application.ScreenUpdating = True

End Sub

Regards,

Robert
 
Upvote 0
Is this what you mean?

Book1
ABCDEFGH
1ClientHdr 2Hdr 3PreparerHdr 5Hdr 6Hdr 7Hdr 8
2Client 1datadataPreparer 4datadatadatadata
3Client 23datadataPrepare 2datadatadatadata
4Client 5datadataPreparer 8datadatadatadata
5Client 6datadataPreparer 9datadatadatadata
6Client 7datadataPreparer 10datadatadatadata
7Client 8datadataPreparer 11datadatadatadata
New



Book1
ABCDEFGH
1ClientHdr 2Hdr 3PreparerHdr 5Hdr 6Hdr 7Hdr 8
2Client 1datadataPreparer 1datadatadatadata
3Client 2datadataPreparer 2datadatadatadata
4Client 3datadataPreparer 3datadatadatadata
5Client 1datadataPreparer 4datadatadatadata
6Client 2datadataPreparer 5datadatadatadata
7Client 3datadataPreparer 6datadatadatadata
8Client 4datadataPreparer 7datadatadatadata
9Client 5datadataPreparer 8datadatadatadata
10Client 6datadataPreparer 9datadatadatadata
11Client 4datadataPreparer 10datadatadatadata
12Client 5datadataPreparer 11datadatadatadata
13Client 6datadataPreparer 12datadatadatadata
Old
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:H15Expression=COUNTIFS(New!$A$2:$A$100,$A2,New!$D$2:$D$100,$D2)textNO
 
Upvote 0
Thanks @Peter_SSs that's exactly what I was looking for. I had a similar formula, but I had it the wrong way round, this works perfect.

Would it be possible to change it, so that instead of highlighting the cells that meet the criteria, it highlights every one that doesn't instead?

That might be useful for another part of the workbook. Thanks again for your help.
 
Upvote 0
Would it be possible to change it, so that instead of highlighting the cells that meet the criteria, it highlights every one that doesn't instead?
Just add =0 to the formula
=COUNTIFS(New!$A$2:$A$100,$A2,New!$D$2:$D$100,$D2)=0

However, if there are any rows that are blank in columns A & D it would highlight those too. If that is your circumstance & you don't want blanks highlighted, post back for a further modification.
 
Upvote 0

Forum statistics

Threads
1,216,087
Messages
6,128,740
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top