I am attempting to create an excel macro to highlight the duplicate values in a rows range of values. I was able to figure out how to get the macro to work for one row at a time, by manually changing the row range for each row (see 'Exhibit 1 - vba Code' - tagged code below). But I have not been able figure out how to get the macro to highlight duplicate values across each and every individual rows range of a 1000+ row worksheet. The goal is to get the macro to run through the entire worksheet and highlight duplicate values contained within each individual row. I attached a 'Small Scale Example of the desired result'. Does anyone know how to accomplish this? Thank you in advance!
Exhibit 1 – vba Code:
[CODE]
Sub Macro1()
' Macro1 Macro
' UpdatebyExtendoffice20161222
Dim x As Integer
Application.ScreenUpdating = False
' Set numrows = number of rows of data.
NumRows = Range("b20:by20", Range("b20:by20").End(xlDown)).Rows.Count
' Select cell b20.
Range("b20:by20").Select
' Establish "For" loop to loop "numrows" number of times.
For x = 1 To NumRows
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
With Selection.FormatConditions(1).StopIfTrue = False
' Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next
Application.ScreenUpdating = True
End Sub
Small Scale Example of the desired result: Attached