I found this code to check for duplicates in column F, works fine if all the data is numbers, how can I change it to work if the data is numbers and letters?
Thought I could just remove the IsNumeric part but I can't make it work, this is being used in Excel 2003.
Thanks
Thought I could just remove the IsNumeric part but I can't make it work, this is being used in Excel 2003.
Thanks
Code:
Sub CheckForDuplicates()
Dim dict As Object
Dim LR As Long, i As Long, v As Variant, strResult As String
Set dict = CreateObject("Scripting.Dictionary")
With ActiveSheet
LR = .Range("F" & .Rows.Count).End(xlUp).Row
For i = 2 To LR
If IsNumeric(Range("F" & i).Value) And WorksheetFunction.CountIf(Columns("F"), Range("F" & i).Value) > 1 Then
If dict.Exists(.Range("F" & i).Value) Then
dict.Item(.Range("F" & i).Value) = dict.Item(.Range("F" & i).Value) & .Range("F" & i).Row & " / "
Else
dict.Add .Range("F" & i).Value, .Range("F" & i).Row & " / "
End If
End If
Next i
End With
For Each v In dict.keys
strResult = strResult & "Duplicates: " & v & vbNewLine & "In Rows: " & _
Left(dict.Item(v), Len(dict.Item(v)) - 1) & vbNewLine & vbNewLine
Next v
If strResult = "" Then
'MsgBox "No duplicates"
Else
MsgBox strResult, , "Duplicates"
End If
End Sub