2

Is there a way of adding another text value that will remain when a lot of other rows get deleted? Right now in row "I", I need to delete any row that has a value that isn't "200" or "900".

Sub macro20()
Dim Rng As Range
Dim x As Long
Set Rng = Range("I1:I" & Range("I65536").End(xlUp).Row)
For x = Rng.Rows.Count To 1 Step -1
    If InStr(1, Rng.Cells(x, 1).Value, "200") = 0 Then
        Rng.Cells(x, 1).EntireRow.Delete
    End If
Next x
End Sub

This is what i have so far but i am not aware of how i would go about adding another text value to keep the row from being deleted.

1 Answer 1

1

Try,

If Rng.Cells(x, 1).Value <> 200 And Rng.Cells(x, 1).Value <> 900 Then

This is for cell values that are true numbers; not for cell values that might contain 200 or 900 as part of a longer text string.

Sign up to request clarification or add additional context in comments.

1 Comment

that works perfectly, thank you :). just a little disappointed that i was stuck on something so simple now :P.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.