Delete cells which contain specific text within a set range

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like to have a macro that in active sheet (say sheet1), for range K30:Z40, it deletes all cells which have text equal to "Pass", "Error" or "Fail".

If cell has some text plus "Pass", "Error" or "Fail" then it should not be deleted (eg. if cell contains "Admin Error" then it should not be deleted if it contains "Error" then it should be deleted).

How do I do that?

Thanks,
Nicola
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If you men to clear the cell, try
VBA Code:
Sub Nick70()
   Dim Ary As Variant
   Dim i As Long
   
   Ary = Array("Pass", "Error", "Fail")
   With Range("K30:Z40")
      For i = 0 To UBound(Ary)
         .Replace Ary(i), "", xlWhole, , False, , False, False
      Next i
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

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