Autofilter method of range class failed

ashleywanless

Board Regular
Joined
Aug 4, 2009
Messages
158
Hi,

I am trying to write a macro which takes data input into a userform and runs various autofilters based on this. A particular part of my code is triggering a Autofilter method of range class failed. The code is

Code:
    If RB1_chk.Value = True Or RB2_chk.Value = True Then
    WSE.Activate
    Range("A:A0").Activate
    WSE.AutoFilterMode = False
    Selection.AutoFilter Field:=CID1, Criteria1:=C1, Operator:=xl & OP1, Criteria2:=C2
    Else
    WSE.Activate
    WSE.AutoFilterMode = False
    *Range("A:AO").AutoFilter Field:=CID1, Criteria1:=C1
    End If

The line with the * infront is the line highlighted yellow. I know the rest of the code is fine as if i replace this line with a msg box that shows fine.

RB1/2 are checkboxes on the form. WSE is a worksheet, CID1 is an integer with a current value of 7. C1 is a string with a value of =29/09/2010

OP1 is a string with a value of Or.


Can anyone think of why this error occours?

Thanks

Ashley
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Have you noticed that in the code you have pasted there is

Range("A:A0").Activate -- its A ZERO
and then there is
*Range("A:AO").AutoFilter Field:=CID1, Criteria1:=C1 -- it's the letter O and not zero
?
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top