Delete Entire Rows Based on Cell Values

后端 未结 3 541
夕颜
夕颜 2021-02-06 13:00

I want in Excel (2003) to take an imported data dump and format it into a report. Most of what I have done has involved recording a macro and then customizing the code where ne

3条回答
  •  旧巷少年郎
    2021-02-06 13:47

    I'm all about brevity.

    Sub DeleteRowBasedOnCriteria()
    Dim RowToTest As Long
    
    For RowToTest = Cells(Rows.Count, 4).End(xlUp).Row To 2 Step -1
    
    With Cells(RowToTest, 4)
        If .Value <> "VFIRE" _
        And .Value <> "ILBURN" _
        And .Value <> "SMOKEA" _
        And .Value <> "ST3" _
        And .Value <> "TA1PED" _
        And .Value <> "UN1" _
        Then _
        Rows(RowToTest).EntireRow.Delete
    End With
    
    Next RowToTest
    
    End Sub
    

提交回复
热议问题