VBA - delete row if cell contains

sherwood16

New Member
Joined
Mar 27, 2012
Messages
24
Hi all,

Trying to search this but having no luck.

I'm after some VBA where I can delete the whole row of a table, if column C contains the word "Charge"?

Can someone help?

Thanks.
 
I love this forum!!!

Thank you very much, did exactly what I needed to do. I will use this code to try and delete any line where "Cancelled" is in Column P. I am assuming I have to modify the 'UBound' but I'll mess around with it for a while until I get stuck again.

Thanks for your help.
Modifying the UBound won't get you anywhere, but you can modify one line in the code to

If Not X(a(i, 1)) = 1 And a(i, Columns("P").Column) <> "Cancelled" Then

which should do what you want.
 
Upvote 0
I know the thread is old but figured I'd give it a shot..

This almost works for me. I need it to find the target word within a string, that is it isn't the only word in the cell. So it will delete the row if the target word in anywhere in column A. So blah blah blah Targetword blah blah it will still delete the row. Currently it has to be the only thing in the cell.

Hoping you find this...:)

Jim
 
Upvote 0
I know the thread is old but figured I'd give it a shot..

This almost works for me. I need it to find the target word within a string, that is it isn't the only word in the cell. So it will delete the row if the target word in anywhere in column A. So blah blah blah Targetword blah blah it will still delete the row. Currently it has to be the only thing in the cell.

Hoping you find this...:)

Jim
Hi Jim,

In the code of the post #7
change this: Const MyTarget = "Charge"
by that: Const MyTarget = "*Charge*"
Instead of the word Charge use what is required

Regards
 
Last edited:
Upvote 0
Hello,

I have had no luck with running for this purpose. I tried to write some code so that it would remove a row if there was data contained anywhere in the row. I would also like to be able to define what text value (case insensitive) that it is looking for in a cell on tab "sheet2".

Is there a way to configured this existing code to do that?

Thanks,

Steve
 
Last edited:
Upvote 0

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