Highlight duplicate cells in multiple ranges random on single sheet

jenkins124

New Member
Joined
Jan 10, 2019
Messages
3
I am trying to figure out how to highlight duplicate cells in 15 different ranges on a single sheet.
Example:
Ranges are: A1:A20, A30:A50: A60:A80, D1:20, D30:D50, etc.
The ranges are not side by side but scattered across the sheet.
I am attempting to do a bunch of loops to do this , but realize there must be a simpler way.
I have seen it done , but only when the ranges are all side by side.

Thanks for any help
Jenkins124
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
With no pattern of what ranges to check and no logic provided as to how you choose the ranges I would think it may be hard to help you.

And you did not provide specific details as to what
highlight duplicates means.

Highlight them with cell color of Green or Yellow or what?
 
Upvote 0
I am slightly familiar with vba so was looking for some guidance, but see it may be easier to actually provide the issue so some code examples could be provided.

The ranges below all have numbers in them.
If there are duplicate numbers between the ranges I would like the cell to highlight in yellow.
No single range (ex: A1:A20) has duplicate numbers within it.

The range of cells are:
A1:A20, A30:A50, A60:A70
D
1:D20, D30:D50, D60:D70
G
1:G20, G30:G50, G60:G70
<strike>
</strike>
J
1:J20, J30:J50, J60:J70

Thanks
<strike></strike>
 
Upvote 0
From the macro recorder (adjust to suit your needs) :
Code:
Sub Macro1()
    Cells.FormatConditions.Delete
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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