i want to check for duplicates with vba. i know one can do so with conditional formatting but in this instance vba will work better.
i added the following code to the worksheet change event
Code: Select all
Dim d As Object, e
Set d = CreateObject("scripting.dictionary")
For Each e In Intersect(Columns(ActiveCell.Column), ActiveSheet.UsedRange)
If e.Value <> vbNullString Then
If Not d.exists(e.Value) Then d(e.Value) = 1 Else _
e.Font.ColorIndex = 4
End If
Next
how can i specify the exact columns i want to check? in my workbook the data lies in columns D5:D24, J5:J24, P5:P24, AB5:AB24 and AH5:AH24. the values which i want highlighted are below that.
your assistance is highly appreciated.