Autofilter method of range class failed

T

Terry K

Hello all, I have a sub that is failing on one line and I am not sure
why. The line is
selection.autofilter field:=6, criteria1:= ">500"
the error that I get is autofilter method of range class failed. The
sub is fairly big, that is why I am only posting the one line. if I end
the sub when it fails here I can go and filter the list based on this
exact same criteria. I have used the recorder to make sure that the
line is coded properly. I seems to match what the recorder gives me. Is
there something special that I need to do when using it in code when
comared to doing it manually or recording it?
If more code is needed please let me know and I will post.
Thanks in advance for any help that anyone can provide.
Thanks Terry
 
T

Terry K

Sorry let's post the complete line that fails
Selection.AutoFilter field:=6, criteria:=">500", Operator:=xlAnd
Thanks Terry
 
T

Tom Ogilvy

Here is what I recored and what you posted:

Selection.AutoFilter field:=6, Criteria1:=">500", Operator:=xlAnd
Selection.AutoFilter field:=6, criteria:=">500", Operator:=xlAnd

See the difference. Your argument is Criteria, but the correct argument is
Criteria1
 
T

Terry K

Sorry about that, my first post I missed the last qualifier and my
second post I missed the 1 - duhh. My code did actaully have the one in
it but it still does fail. Any ideas as to what I can try to determine
why it is failing?
Thanks Terry
 
T

Tom Ogilvy

Sheet protected.

Selection doesn't include 6 columns

I guess it could be a number of things, but I have never had a problem with
it when it is applied to an appropriate range.
 
T

Terry K

Not sure either. It does have many more than 6 columns and it is not
protected. I am not sure either. If I ever do get it figured out I will
post what the result was. Thanks for the help. Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top