Macro to KEEP only the rows containing certain text, delete the rest.

linda88

New Member
Joined
Mar 23, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Im looking for a macro/code to KEEP only the rows containing certain text, and delete the remaining rows. This is a little tricky because for example I want to keep rows containing "xxxx" and to keep rows containing "yyyy", and "zzzz", then delete or clear all remaining rows.
The tricky part is that once the code find the rows containing "xxxx" it cannot immediately delete ALL other rows because some of those rows may contain "yyyy" or "zzzz".
 
I meant excel 2003
Yes, that does explain it. XL2BB is only designed to work with Excel 2007 and later & won't be altered to try to work with versions older than that, sorry. You are using a very old version! :)

Another option is to simply copy and paste from Excel and describe what you have posted. Example, this is the range D1:E10

54677a
yjthsacvb
yyyyc
77678d
67756223e
xxxxf
76456g
897809h
zzzzi
gtrfryhrgj
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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