VBA Code:
Sub HighlightDuplicates()
Dim rng As Range
Dim cell As Range
Dim dict As Object
' Set the range of cells to check for duplicates
Set rng = Range("A1:A100") ' Change the range as desired
' Create a dictionary object to store the unique values
Set dict = CreateObject("Scripting.Dictionary")
' Loop through each cell in the range
For Each cell In rng
' Check if the value already exists in the dictionary
If dict.Exists(cell.Value) Then
' Highlight the cell as a duplicate
cell.Interior.Color = RGB(255, 0, 0) ' Change the color as desired
Else
' Add the value to the dictionary
dict.Add cell.Value, 0
End If
Next cell
End Sub