Macro-Compare two columns and highlight rows with duplicates

ffionnah

Board Regular
Joined
Jun 12, 2018
Messages
61
Hi all,
I have been searching high and low for a macro to compare 2 columns within a range (possibly selected) and highlight the rows that have duplicate values.

The columns would be:
Column 1 = AO
Column 2 = AS

Within the range selected, those 2 columns will always be the 2 being compared. If there is a way to make the range from the Do Until (Specifically column AO) ActiveCell.Value = Empty, that would be perfect also.

There are values in AO based on a macro I have that identifies unique names and distributes a unique number for those names. For instance, 3 rows in that selection may all be given the unique number of "1" because the name is the same within the range/criteria.

A basic example of this is:

Name: Unique #:
ABC123 1
ABF124 2
ABC123 1
ABG125 3
ABC123 1
ABF124 2


With that being said, I need AO to vlookup to AS, find duplicates and highlight the entire row with the duplicate.


I cannot use conditional formatting because there are already duplicates within AO, as shown above.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I thought I posted but i do not see it; After much digging, I threw a few things together

This macro is only highlighting the first row, what am I doing wrong?!

Code:
 Sub HighlightMatch()Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
For Each cell In WorkRng
    If WorkRng.Cells(i, 43).Value = WorkRng.Cells(i, 44).Value Then
        WorkRng.Cells(i, 44).EntireRow.Interior.Color = RGB(255, 255, 0)
    End If
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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