Need help deleting rows containing specific data

Henner

Board Regular
Joined
May 16, 2002
Messages
174
Hi

Firstly, a message for Jim North if you read this. Many thanks for the macro you provided me with today - it does a great job.
------------------------

I need to delete all rows where a cell in column A contains the word BITS, and a zero exists in the cell in column D - on the same rows only. I do not want to delete any rows where there is a zero in column D but the word BITS doesn't exist in cells in column A.

I know this can be done using AutoFilter and filtering on columns A and D. The problem is the file contents changes each day so if I use AutoFilter, delete the relevant rows and record it in a macro, it may not delete the correct rows the next day.

Can anyone provide me with some VBA code I can copy into a macro which searches for the word BITS and a zero on the same row and deletes these rows?

Thank you,
Paul
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I would still use an Autofilter in a macro, BUT, I would select the ENTIRE columns, instead of just the current area. That way your macro would still work after that. Make sure that you use the Visible Cells only feature too to make it as general as possible.
 
Upvote 0
Thank you very much for your help, Juan,

I wasn't aware of the Special features in the 'Go To..' section before. These have helped me solve some other problems as well.

Best regards,
Paul
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,569
Members
449,038
Latest member
Guest1337

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