Hi Guys,
I need a function that can detect duplicates in a specified Excel column. I have this one but it does not work properly. It cannot distinguish between the value "46.500" and the value "46.5000". The countif function probably compares cells as numbers. These cells are formatted as text and I have even tried to add an apostrophe prior the numbers. No luck.
Function check_duplicates(column As String)
LastRow = Range(column & "65536").End(xlUp).row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range(column & "1:" & column & LastRow), Range(column & x).Text) > 1 Then
check_duplicates = x ' return row with a duplicate
x = 1
Else
check_duplicates = 0
End If
Next x
End Function
The catch is the line with Countif.
Does anyone know how to force VBA CountIf function to compare cells as strings or other way to check for duplicates in VBA?