delete Autofilter Field resullt using the header Name

I tried to always use an autofilter to find the empty cells before removing them but I’m stuck with it . instead i used SpecialCells function Since i want to delete the Empty cells. So it Works but if I want to delete other celles dipending other special criteria than blank or somting that is not specified in SpecialCells Methode , i will have a problem but So far here is a solution. i Hope that will help some one. Here is a code. If you have a solution using Autofilter please share. Thanks

Sub data()

 Dim Wrksh As Worksheet, DurtyRows As Range, LstRw As Long


Set WorkSh = Sheets("feuil2")

    With WorkSh
    LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
    Set DurtyRows = .Range("A1:A" & LstRw).SpecialCells(xlCellTypeBlanks)
    DurtyRows.EntireRow.Delete
    .AutoFilterMode = False
  End With

End Sub

Leave a Comment