View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Delete rows with different criteria

That didn't quite work. I don't think I can delete the "Used range" because
I have stuff in rows 1 through 10 that I want to keep. Does that make sense?

I think it may also be hiding all the fields and not filtering them
correctly. I use 700 rows and on two of the sheets 700 rows are hidden...
none are deleted.


"ben" wrote:

change your criteria to show ONLY THE LINES YOU PREVIOUSLY HAD HIDDEN and
then delete all rows


Selection.AutoFilter Field:=8, Criteria1:="<", Operator:=xlAnd
Selection.AutoFilter Field:=14, Criteria1:="=0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="<7.00", Operator:=xlAnd
activesheet.usedrange.delete
Sheets("AG Non Call").Select
Selection.AutoFilter Field:=8, Criteria1:="<#N/A N Ap", Operator:=xlAnd
Selection.AutoFilter Field:=14, Criteria1:="<0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="<7.00", Operator:=xlAnd
Sheets("CORPS").Select
Selection.AutoFilter Field:=14, Criteria1:="<0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="<8.00"
activesheet.usedrange.delete

test this code before finalizing and saving
--
When you lose your mind, you free your life.


"John" wrote:

I have a simple macro that filters (hides) the data that is unapplicable in
each worksheet. How would I make the macro delete the rows that it is hiding
in the autofilter? My code is below.

THANKS!

Selection.AutoFilter Field:=8, Criteria1:="<", Operator:=xlAnd
Selection.AutoFilter Field:=14, Criteria1:="0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="=7.00", Operator:=xlAnd
Sheets("AG Non Call").Select
Selection.AutoFilter Field:=8, Criteria1:="=#N/A N Ap", Operator:=xlAnd
Selection.AutoFilter Field:=14, Criteria1:="0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="=7.00", Operator:=xlAnd
Sheets("CORPS").Select
Selection.AutoFilter Field:=14, Criteria1:="0", Operator:=xlAnd
Selection.AutoFilter Field:=18, Criteria1:="=8.00"