Hi ,

Some one help me in excel macro

If the cell vale is other than 2480, 4465, 3140,2689 i want the entire row to be deleted.

regards
Victor

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

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

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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.