VBA Delete rows if cell contains specific text within a string

gray_b

New Member
Joined
Apr 17, 2019
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Expanding on VBA Delete rows if cell contains specific text

1 - How can I make it search for say "Dog" within a string in a cell of say "My Dog plays games"

Changing - If (Cells(i, "B").Value) = "Dog"

to something like

If (Cells(i, "B").Value) = "*Dog*"

That does not work, but any ideas please.

Also
2 - To search for multiple words for say "Dog" "Cat" "Mouse" within a strings of say "My Dog plays games" and "My Cat is sleeping" and "Mouse has 4 legs"

Changing - If (Cells(i, "B").Value) = "Dog" or "Cat" or "Mouse"

That does not work, but any ideas please.
 
You're welcome. Glad that sorted the issue. Thanks for the follow-up. :)
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,225,738
Messages
6,186,734
Members
453,369
Latest member
juliewar

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