Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofilter problem

Status
Not open for further replies.

TC2000

Programmer
Dec 28, 2000
32
HK
When I run the following instruction, I got the error
"Autofilter method of Range class failed"

Selection.AutoFill Destination:=Range("G10:G" & lastrowx), Type:=xlFillDefault
Range("G10:G35").Select
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Rows("8:8").Select
Selection.Delete Shift:=xlUp
Rows("1:5").Select
Selection.Delete Shift:=xlUp
Columns("O:O").Select
Selection.Insert Shift:=xlToRight

' Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="=BUY*", Operator:=xlOr, Criteria2:="=SELL*", VisibleDropDown:=True

Best regards
 
Columns("O:O").Select
' select one column (field)
Selection.Insert Shift:=xlToRight
' shift columns to the right, selection still one column
Selection.AutoFilter Field:=3, Criteria1:="=BUY*", Operator:=xlOr, Criteria2:="=SELL*", VisibleDropDown:=True
' trying to apply filter on third column of selection when you only have one column selected

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top