Highlight Some Duplicates but Not Others

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
I'm failing at trying to come up with a statement that will only highlight the numerical values that are duplicates in a single column rather.

i.e.:

[TABLE="width: 69"]
<colgroup><col></colgroup><tbody>[TR]
[TD]95210452[/TD]
[/TR]
[TR]
[TD]95212176[/TD]
[/TR]
[TR]
[TD]95212176[/TD]
[/TR]
[TR]
[TD]95214475[/TD]
[/TR]
[TR]
[TD]95219924[/TD]
[/TR]
[TR]
[TD]95219924[/TD]
[/TR]
[TR]
[TD]97146350[/TD]
[/TR]
[TR]
[TD]95228184[/TD]
[/TR]
[TR]
[TD]95230612[/TD]
[/TR]
[TR]
[TD]95234230[/TD]
[/TR]
[TR]
[TD]UPS[/TD]
[/TR]
[TR]
[TD]95241941[/TD]
[/TR]
[TR]
[TD]UPS[/TD]
[/TR]
[TR]
[TD]UPS[/TD]
[/TR]
[TR]
[TD]95248672[/TD]
[/TR]
[TR]
[TD]FEDEX[/TD]
[/TR]
[TR]
[TD]95252010[/TD]
[/TR]
</tbody>[/TABLE]


I don't care about UPS or anything that isn't an 8 digit number,

If 8 digits, and duplicate found in column "U" then highlight. If not.. leave alone.

Thanks guys.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Select the range you want to format conditionally>Home>New Rule>Use a Formula

formula is: =AND(LEN($U1)=8,COUNTIF($U:$U,$U1)>1)

choose format and click OK
 
Upvote 0
Sphinx404,

Here is a macro solution for you to consider that will bold duplicate 8 digit numbers.

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub HighlightDuplicate8digitnumericalvalues()
' hiker95, 11/14/2017, ME1031445
Application.ScreenUpdating = False
Dim rng As Range, u As Range
Set rng = Range(Range("U1"), Range("U" & Rows.Count).End(xlUp))
For Each u In rng
  If IsNumeric(u) And Len(u) = 8 Then
    If Application.CountIf(rng, u) > 1 Then
      u.Font.Bold = True
    End If
  End If
Next u
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the HighlightDuplicate8digitnumericalvalues macro.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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