filter that yeilds no results
Matt,
My guess is that your lastrow function returns either null or zero when there are no rows matching your criteria, so the resulting range to delete is A2:AQ1; your header row.
I think that a simple MAX function will sort this out. The sub I copied below adds a new variable (lRow) to look at the result of your (lastrow(ActiveSheet) + 1) argument and take the maximum of that figure or 2. Thus, if the lastrow function returns null, then 2 is larger and the resulting range is A2:AQ2. Hope this helps.
Ben
Dim lRow As Long
Set myrange = Range("A1:" & ConvertToCol(LastCol(ActiveSheet)) & lastrow(ActiveSheet))
myrange.AutoFilter
myrange.AutoFilter Field:=12, Criteria1:="=0", _
Operator:=xlOr, Criteria2:="=2E"
lRow = WorksheetFunction.Max(2, lastrow(ActiveSheet) + 1)
Range("A2:aq" & lRow).SpecialCells(xlCellTypeVisible).Delete
myrange.AutoFilter
|