Link to home
Start Free TrialLog in
Avatar of Euro5
Euro5Flag for United States of America

asked on

VBA remove rows

I need VBA code to remove rows where
C = Unkn OR D = (blank)

Service Type      Package Type      Zone      Imp/Exp
IP      Box      A      Export
IP      Box      A      Import
IP      Box      B      Export
IP      Box      C      Export
IP      Box      C      Import
IP      Box      D      Export
IP      Box      F      (blank)
IP      Box      I      Export
IP      Box      J      Export
IP      Box      N      Export
IP      Box      O      Export
IP      Box      P      Import
IP      Box      PR      Export
IP      Box      Unkn      Import
TEST.xlsx
Avatar of Professor J
Professor J

please try below code

Sub deleterow()
Dim x As Long
LastRow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = LastRow To 1 Step -1
    If UCase(Cells(x, "C").Value) = "Unkn" Then
        Rows(x).Delete
    End If
Next
On Error Resume Next
Columns("D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub

Open in new window

SOLUTION
Avatar of Excel amusant
Excel amusant

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Euro5

ASKER

Thanks so much!