VBA Code to Highlight Duplicates in Excel

This code highlights duplicate values in the selected range.

VBA Code:

Sub HighlightDuplicates()
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
    Selection.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
    Selection.FormatConditions(1).StopIfTrue = False
End Sub
Join Our Telegram Group techguruplus telegram group Join Our WhatsApp Group techguruplus whatsapp group

Leave a Comment