Delete Row Based on Word in Cell

cjvenables

Board Regular
Joined
Aug 2, 2011
Messages
65
Hello,

I'm trying to search each cell in column C and see if contains OPEN, CLOSED, or PROCESSED. If they do not contain any 1 of those 3 words, I want to delete the entire row.

I have been unsuccessful with my code so far, hopefully you guys can provide some guidance.

Thanks so much,

Code:
Sub Delete()

Application.ScreenUpdating = False
Dim rng As Range
Dim colwords As Variant

colwords = Array("OPEN", "CLOSED", "PROCESSED")

For Each rng In Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)
        If rng.Value <> colwords Then EntireRow.Delete
Next rng

Application.ScreenUpdating = True
MsgBox "Your Macro is Complete!", vbOKOnly, "Macro Status"

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try

Code:
Sub Delete()

Application.ScreenUpdating = False
Dim rng As Range

colwords = Array("OPEN", "CLOSED", "PROCESSED")

For Each rng In Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)
        If IsError(Application.Match(rng.Value, Array("OPEN", "CLOSED", "PROCESSED"), 0)) Then EntireRow.Delete
Next rng

Application.ScreenUpdating = True
MsgBox "Your Macro is Complete!", vbOKOnly, "Macro Status"

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,297
Members
448,564
Latest member
ED38

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