View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Matthew Dyer Matthew Dyer is offline
external usenet poster
 
Posts: 178
Default filter that yeilds no results

On Tuesday, October 2, 2012 6:32:19 PM UTC-7, Matthew Dyer wrote:
I'm trying to delete rows via results from a filter. The problem i'm running into is if there is no criteria that matches the filter then the header row is deleted. here's the Code i'm working with. Converttocol, lastcol and lastrow functions work fine. - Set myrange = Range("A1:" & ConvertToCol(LastCol(ActiveSheet)) & lastrow(ActiveSheet)) myrange.AutoFilter myrange.AutoFilter Field:=12, Criteria1:="=0", _ Operator:=xlOr, Criteria2:="=2E" Range("A2:aq" & (lastrow(ActiveSheet) + 1)).SpecialCells(xlCellTypeVisible).Select Selection.Delete myrange.AutoFilter


Thanks for the reply Ben. I found another solution in between posting and finding your solution. I just entered an error handler that would skip the delete portion of the code in the event there is no visible data to select. I'll give your solution a shot when time allows. Again, Thanks for the Reply!!