Highlight duplicate values

Closed
yasserhammami Posts 1 Registration date Thursday February 3, 2011 Status Member Last seen February 3, 2011 - Feb 3, 2011 at 06:49 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 8, 2011 at 04:16 PM
Hello,

I need some help with a macro to highlight duplicate values in different columns that have to the same company ID. so I need 2 conditions in this macro.

1. value in column G match value in column W

and

2. those 2 values belongs to the same comapny = companies are identified in colomun A with a company ID.

I've found this Macro and tried to use but it's highlighting the same values in colomun G and W regardless if they have the same company id or not in colomun A.

Sub HighlightDups()
Dim i, LastRowG, LastRowW
LastRowG = Range("G" & Rows.Count).End(xlUp).Row
LastRowW = Range("W" & Rows.Count).End(xlUp).Row
Columns("G:G").Interior.ColorIndex = xlNone
Columns("W:W").Interior.ColorIndex = xlNone
For i = 1 To LastRowG
If Application.CountIf(Range("W:W"), Cells(i, "G")) > 0 Then
Cells(i, "G").Interior.ColorIndex = 36
End If
Next
For i = 1 To LastRowW
If Application.CountIf(Range("G:G"), Cells(i, "W")) > 0 Then
Cells(i, "W").Interior.ColorIndex = 36
End If
Next
End Sub

I hope someone could help me to edit it as I have no VB or any programing background.

Thank you in advance



1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Feb 8, 2011 at 04:16 PM
Could you please upload a sample EXCEL file WITH sample data, macro, formula , conditional formatting etc on some shared site like https://authentification.site , http://docs.google.com, http://wikisend.com/ , http://www.editgrid.com etc
AND post back here the link to allow better understanding of how it is now and how you foresee. Based on the sample book, could you re-explain your problem too.


Note:
your data need not be to be real data but a good representative of how data looks like
0