I am using 2007. I tried conditional formatting, but it highlighted every cell the same colour. What I really need is for it to find half a dozen cells that are the same and highlight red, another few and highlight yellow etc just to break them up a bit and easier to see.
You had said one colour would suffice but if you want to differentiate then yes, I think a macro will be best.
I have assumed ..
- The data to be coloured is in column H, starting at row 2 (heading in row 1).
- Columns Y and Z are available for the code to use as helper columns.
If you need help to adapt to your particular circumstances, post back with more details in relation to my assumptions. Also post back if you need help with how to implement the code.
Test in a
copy of your workbook.
<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> ColourDupes()<br> <SPAN style="color:#00007F">Dim</SPAN> aData, aDupes, vDupVal<br> <SPAN style="color:#00007F">Dim</SPAN> rData <SPAN style="color:#00007F">As</SPAN> Range<br> <SPAN style="color:#00007F">Dim</SPAN> lColr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, lLastRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, j <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br> <br> <SPAN style="color:#00007F">Set</SPAN> rData = Range("H2", Range("H" & Rows.Count).End(xlUp))<br> aData = rData.Value<br> Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br> rData.Interior.ColorIndex = xlNone<br> Range("Y2").Formula = "=COUNTIF(H:H,H2)>1"<br> Range("H1", Range("H" & Rows.Count).End(xlUp)).AdvancedFilter _<br> Action:=xlFilterCopy, CriteriaRange:=Range("Y1:Y2"), _<br> CopyToRange:=Range("Z1"), Unique:=<SPAN style="color:#00007F">True</SPAN><br> lLastRw = Range("Z" & Rows.Count).End(xlUp).Row<br> <SPAN style="color:#00007F">If</SPAN> lLastRw > 1 <SPAN style="color:#00007F">Then</SPAN><br> lColr = 3<br> aDupes = Range("Z2:Z" & lLastRw).Value<br> <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> lLastRw - 1<br> vDupVal = aDupes(i, 1)<br> lColr = lColr + 1<br> <SPAN style="color:#00007F">For</SPAN> j = 1 <SPAN style="color:#00007F">To</SPAN> <SPAN style="color:#00007F">UBound</SPAN>(aData, 1)<br> <SPAN style="color:#00007F">If</SPAN> aData(j, 1) = vDupVal <SPAN style="color:#00007F">Then</SPAN><br> rData.Cells(j, 1).Interior.ColorIndex = lColr<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">Next</SPAN> j<br> <SPAN style="color:#00007F">Next</SPAN> i<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> Range("Y1").Resize(lLastRw + 1, 2).ClearContents<br> Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>