Hello Excel lovers,
I have a column (column A) with names.
When I add a name to the column, I play a macro that deletes the name if the name is already in the column!
But my solution doesn’t work.
When I play the macro it always deletes the last name!
Why?!
I think it goes wrong with the end(xldown) part.
When I play the macro step by step (with F8) the value of end(xldown) = 4121?!?!?!
Sub Test()
i = 1
Do Until Cells(i, 1).Value = ""
If Cells(1, 1).End(xlDown).Value = Cells(i, 1).Value Then
MsgBox "This name already exists!"
Cells(1, 1).End(xlDown).EntireRow.Delete
End If
i = i + 1
Loop
End Sub
Who can help me?
I have a column (column A) with names.
When I add a name to the column, I play a macro that deletes the name if the name is already in the column!
But my solution doesn’t work.
When I play the macro it always deletes the last name!
Why?!
I think it goes wrong with the end(xldown) part.
When I play the macro step by step (with F8) the value of end(xldown) = 4121?!?!?!
Sub Test()
i = 1
Do Until Cells(i, 1).Value = ""
If Cells(1, 1).End(xlDown).Value = Cells(i, 1).Value Then
MsgBox "This name already exists!"
Cells(1, 1).End(xlDown).EntireRow.Delete
End If
i = i + 1
Loop
End Sub
Who can help me?