Remove Customers Starting With an "A"

wayneshirley

Board Regular
Joined
Jun 23, 2003
Messages
140
Hi there,

I need some code to add to a macro that will delete customer account names that start with an "A" in column C. Specifically it needs to find customer names starting with the letter "A" and delete that entire row.

Can anyone help me please?

Thank you.
 
worked like a charm. I have several cases like this one. I should set the number of characters each cell should contain to get the row deleted, right?

thank you a lot
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Well, you were comparing the output of the Left function to the string "ND" which is two characters long. So if you only ever pull 1 character from the cell's value it isn't ever going to match against and be the same as a string which contains two characters. Make sense? So you just need to set the number of characters to be the same value as the length of whatever you are comparing against. So if you wanted to check using the first three characters you might have:

Code:
If Left(ActiveCell.Value,3) = "NDF" Then

for example.
 
Upvote 0
I understand. But something came up (something always comes up)...
I´m trying to do this same macro for these cells
4110-206
4110-101
4120-201
and so on.

But using this doesn´t work:

Sheets("Datos").Select
Range("g65536").End(xlUp).Select
While ActiveCell.Row > 2
If Left(ActiveCell, 8) = "4110-206" Then
ActiveCell.EntireRow.Delete
End If
ActiveCell.Offset(-1, 0).Select
Wend

is it the dash? can you help me with it?
 
Upvote 0
No, what you have is correct. If it isn't working then it suggests that potentially the data in the sheet has leading spaces at the start? It would be useful to check with a worksheet formula - point the following formulas at one of these rows you would expect to be deleted:

=LEFT(A1,8)

Replacing A1 with whatever the cell reference is holding the value. Compare the output with what the code is looking for (ie "4110-206").
 
Upvote 0
I don´t know what´s wrong... using the formula you suggested "4110-206" appears as result, so the command is working correctly.
But it doesn´t appear to work in my macro...
 
Upvote 0
got it...this was the problem

While ActiveCell.Row > 2

this avoids row number 2 to qualify for "If left..." conditional. 4110-106 was on row 2. i tried it on other items and it worked, found out only row 2 was left untouched, checked macro, found the above and changed it to

while ActiveCell.Row > 1

DOne...
Thank you very very much, man...
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top