Sorry this is a bit late (I've had tech problems) but:
THANK YOU!
Thanks again
Charles
Sorry this is a bit late (I've had tech problems) but:
THANK YOU!
I now have a macro that identifies duplicates
Thanks again
Charles
Charles
Give this a try. You will need to change the end value in the For/Next loop based on how many rows your data contains (or just set it to a large number to cover any case).
Let me know how it works!
Sub FindDupes()
Dim varCol As String
varCol = Inputbox("Please enter the column number to search.", "Duplicates")
If Not (IsNumeric(varCol)) Then
MsgBox "Please enter in the column number only"
FindDupes
End If
For x = 1 To 1000
Set Sheet = ActiveSheet
If Sheet.Cells(x, varCol * 1).Value = Sheet.Cells(x + 1, varCol * 1).Value Then
MsgBox "Duplicate found at row " & x
Sheet.Cells(x, varCol * 1).Select
Exit Sub
End If
Next x
End Sub
Slight improvement - try this code instead (should avoid any recursive errors)
Sub FindDupes()
Dim varCol As String
SelectColumn:
varCol = Inputbox("Please enter the column number to search.", "Duplicates")
If Not (IsNumeric(varCol)) Then
MsgBox "Please enter in the column number only"
GoTo SelectColumn
End If
For x = 1 To 1000
Set Sheet = ActiveSheet
If Sheet.Cells(x, varCol * 1).Value = Sheet.Cells(x + 1, varCol * 1).Value Then
MsgBox "Duplicate found at row " & x
Sheet.Cells(x, varCol * 1).Select
Exit Sub
End If
Next x
End Sub