3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by victor Thomas.D
0

Stop spamming the forum. Ask your question in one thread when they are all related to the same subject.

0
Sub test()
    Dim r As Range
    For Each r In ActiveSheet.UsedRange
        Select Case r.Value
            Case 2480, 4465, 3140, 2689
                r.Delete
        End Select
    Next
End Sub
0

Sorry i cannot understand it ..

I have attached the excel where i want to delete the entire row if the value other than 2480,2689,3140,4465 in column("A:A").


I want values other than 2480,2689,3140,4465 to be deleted.

Attachments
0

I've changed the macro so the rows with 2480 etc. are NOT deleted.
Overread that they should be kept, sorry for that.

In Excel press Alt+F11
Select the worksheet you want to change.
Paste the code snippet below.
Return to Excel.
Go to menu: Extra > Macro > Run Macro: Test
Et voila!

Sub DeleteTheRowsWithoutMyNumbers()
    Dim r As Range
    For Each r In ActiveSheet.UsedRange
            Select Case r.Value
                   Case NOT 2480, 4465, 3140, 2689
                         r.Delete
             End Select
   Next
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.