I need a function to detect duplicates formatted as text.
This cannot distinguish between \"46.500\" and\"46.5000\". CountIf probably compares cells as numbers. Thes
Assuming all the "text" cells are textual representations of numbers, then the following change will work:
Function check_duplicates(column As String)
Dim lastrow As Long
Dim x As Long
lastrow = Range(column & "65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range(column & "1:" & column & lastrow), Val(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
It coerces the value of the criteria cell to a value by the use of the Val
function