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. These cells are formatted as text. I tried to add an apostrophe prior the numbers.
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
Does anyone know how to force CountIf to compare cells as strings or other way to check for duplicates in VBA?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…