We help IT Professionals succeed at work.
Get Started

Deleting a bunch of rows.  Autofilter

Last Modified: 2014-01-10
I have another delete rows request... prefer with autofilter, (it is a bigger file and will delete around 25,000 rows)
On column AG or ActiveSheet.UsedRange.AutoFilter Field:=33,

How would I modify the code below to delete rows based on the following:

I want to delete everything, except the blanks, and dates = today, and yesterday.

Ending with the filter on only today and yesterdays records.  (no blanks)  -R-

Sub Macro()
    ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:="=-", _
        Operator:=xlOr, Criteria2:= _
    LastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row
    LastColumn = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
    Range(Range("A2"), Cells(LastRow, LastColumn)).SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
End Sub 

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 36 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE