Filter Error

Joined
Sep 7, 2009
Messages
1
Reaction score
0
Hi,

This code help me delete the data which is older than 36 days. but when I run this code for all the sheets (I have 50 sheets), I get the error "Run-time error '1004' Application-defined or obeject-defined error"

Sub Filter()
lr = Sheet2.Cells(Rows.Count, "a").End(xlUp).Row
Sheet2.Range("a1:a" & lr).AutoFilter Field:=1, Criteria1:="<" & Date - 36 'put the same no as of the month
Sheet2.Range("a2:a" & lr).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Sheet2.Range("a1:a" & lr).AutoFilter

lr = Sheet3.Cells(Rows.Count, "a").End(xlUp).Row
Sheet3.Range("a1:a" & lr).AutoFilter Field:=1, Criteria1:="<" & Date - 36 'put the same no as of the month
Sheet3.Range("a2:a" & lr).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Sheet3.Range("a1:a" & lr).AutoFilter

End Sub




 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top