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.:

95210452
95212176
95212176
95214475
95219924
95219924
97146350
95228184
95230612
95234230
UPS
95241941
UPS
UPS
95248672
FEDEX
95252010

<colgroup><col></colgroup><tbody>
</tbody>


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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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