Need macro to delete rows not containing certain text

Joined
Sep 28, 2013
Messages
1
Reaction score
0
I have a code that will delete all rows that do not contain "11328" in column A. However, I have 45 other values that I need to enter, and I cannot figure out how to expand the code. I know very little about vba. If someone show me how to add additional values to my code I will be endlessly appreciative.

-DFB

Here's what I have:

Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If InStr(Cells(row_index, "A").Value, "11328") = 0 Then
Cells(row_index, "A").EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top