Natalie50208
New Member
- Joined
- Jul 17, 2007
- Messages
- 42
I am trying to create a macro that will isolate and delete unnecessary data. However, I am receiving an error. I believe I may need to use an 'IF' statement rather than using auto.filter.
I'm trying to determine what value/statement I should be using.....
Here's a copy of my initial attempt (the part that is highlighted on VB is bolded):
I'm trying to determine what value/statement I should be using.....
Here's a copy of my initial attempt (the part that is highlighted on VB is bolded):
Rich (BB code):
Rows("1:2").Select
Selection.Delete Shift:=xlUp
Cells.Select
Selection.Sort Key1:=Range("R2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.AutoFilter
Selection.AutoFilter Field:=18, Criteria1:="=1006", Operator:=xlOr, _
Criteria2:="=1016", Operator:=xlOr, _
Criteria3:="=1017", Operator:=xlOr, _
Criteria4:="=1018", Operator:=xlOr, _
Criteria5:="=1019", Operator:=xlOr, _
Criteria6:="=1024", Operator:=xlOr, _
Criteria7:="=1258", Operator:=xlOr, _
Criteria8:="=1260", Operator:=xlOr, _
Criteria9:="=1363", Operator:=xlOr, _
Criteria10:="=2416", Operator:=xlOr, _
Criteria11:="=2417", Operator:=xlOr, _
Criteria12:="=2451", Operator:=xlOr, _
Criteria13:="=2596", Operator:=xlOr, _
Criteria14:="=2671", Operator:=xlOr, _
Criteria15:="=8711", Operator:=xlOr, _
Criteria16:="=2751"
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.ShowAllData
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=7
Cells.Select
Range("H1").Activate
Selection.Sort Key1:=Range("K2"), Order1:=xlAscending, Key2:=Range("AN2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=11, Criteria1:="0"
ActiveWindow.SmallScroll ToRight:=21
Selection.AutoFilter Field:=40, Criteria1:="<1/1/2009", Operator:=xlAnd
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.ShowAllData
End Sub
Last edited by a moderator: