![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
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?
__________________
Best regards, Martin J.A. Maatman Oonk |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
I'm assuming that you are entering the new name on the next available row? The value is finding it'self as a match and then deleting it'self. Try this...
Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|