To identify duplicate and duplicates has to highlight

Mahesh C A

New Member
Joined
Mar 27, 2018
Messages
6
Dear Team,

Could you please help me to write VBA to identify duplicates and same has to highlight.

Please find below mentioned table to identify following duplicates and entire row should be highlighted.

Currently, I am using "CONCATENATE"(Country & Number) to identify duplicate and conditional format to highlight entire row as per status column.

[TABLE="width: 257"]
<tbody>[TR]
[TD]Country
[/TD]
[TD] Secuirty
[/TD]
[TD] Number
[/TD]
[TD]Satus
[/TD]
[/TR]
[TR]
[TD]GB
[/TD]
[TD] A1
[/TD]
[TD="align: right"]456
[/TD]
[TD="align: center"]TRUE
[/TD]
[/TR]
[TR]
[TD]GB
[/TD]
[TD] A2
[/TD]
[TD="align: right"]456
[/TD]
[TD="align: center"]FALSE
[/TD]
[/TR]
[TR]
[TD]US
[/TD]
[TD] B1
[/TD]
[TD="align: right"]789
[/TD]
[TD="align: center"]TRUE
[/TD]
[/TR]
[TR]
[TD]US
[/TD]
[TD] B2
[/TD]
[TD="align: right"]789
[/TD]
[TD="align: center"]FALSE
[/TD]
[/TR]
[TR]
[TD]EU
[/TD]
[TD] C1
[/TD]
[TD="align: right"]321
[/TD]
[TD="align: center"]TRUE
[/TD]
[/TR]
[TR]
[TD]EU
[/TD]
[TD] C2
[/TD]
[TD="align: right"]321
[/TD]
[TD="align: center"]FALSE
[/TD]
[/TR]
[TR]
[TD]HK
[/TD]
[TD] D1
[/TD]
[TD="align: right"]951
[/TD]
[TD="align: center"]TRUE
[/TD]
[/TR]
[TR]
[TD]HK
[/TD]
[TD] D2
[/TD]
[TD="align: right"]951
[/TD]
[TD="align: center"]FALSE
[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advance,

Best Regards,
Mahesh
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assuming the columns are A,B,C,D... in the Status column use the formula
=COUNTIFS($A$2:$A2,$A2,$C$2:$C2,$C2)
and copy down. This counts the number of times both the Country and the number have appeared up to that row. If it's the first occurrence, the value will be 1.
So your conditional formatting should use the formula
=($D2>1)

sometimes this isbetter depending on your requirements, in this case it would falsely give the first row a 1 so you would have to exclude conditional formating for row 2
It counts the number of times both the Country and the number have appeared between row 2 and the row above (hence why it won't work here)
=COUNTIFS($A$2:$A1,$A2,$C$2:$C1,$C2)
If it's the first occurrence, the value will be 0.
So your conditional formatting should use the formula
=($D2>0)

HTH
 
Last edited:
Upvote 0
Assuming the columns are A,B,C,D... in the Status column use the formula
=COUNTIFS($A$2:$A2,$A2,$C$2:$C2,$C2)
and copy down. This counts the number of times both the Country and the number have appeared up to that row. If it's the first occurrence, the value will be 1.
So your conditional formatting should use the formula
=($D2>1)

sometimes this isbetter depending on your requirements, in this case it would falsely give the first row a 1 so you would have to exclude conditional formating for row 2
It counts the number of times both the Country and the number have appeared between row 2 and the row above (hence why it won't work here)
=COUNTIFS($A$2:$A1,$A2,$C$2:$C1,$C2)
If it's the first occurrence, the value will be 0.
So your conditional formatting should use the formula
=($D2>0)

HTH

Thank you so much !
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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