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
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