I want to delete all rows where "name" is found in Range B:B
So I'm using this and it only does like 5 or 6 rows then stops... I don't know why!
What am I screwing up?![]()
Please Login or Register to view this content.
I want to delete all rows where "name" is found in Range B:B
So I'm using this and it only does like 5 or 6 rows then stops... I don't know why!
What am I screwing up?![]()
Please Login or Register to view this content.
Last edited by Tortus; 02-15-2013 at 01:19 PM.
When you delete the row, Excel loses track of where it is:
If you delete row 4, excel moves the rows up so row 5 becomes row 4, but row 4 has already been through your loop, so Excel moves on to row 5 (which was 6). You can test this by adding:
One approach is to count backwards from![]()
Please Login or Register to view this content.
e.g.:![]()
Please Login or Register to view this content.
(in case it isn't obvious - this works because if you choose to delete a row, the rows above, and row numbering, are unaffected)![]()
Please Login or Register to view this content.
Another (better) approach would be to add an autofilter to the range in question, filter for "name", delete all rows from beneath the header down then remove autofilter. Record a macro to get the syntax.
Last edited by Cheeky Charlie; 02-15-2013 at 01:12 PM. Reason: code tags, why counting backwards works
CC
If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.
Ok, thank you. I'll record filtering for name and delete rows. Didn't think about doing that...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks