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
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

sachin.acharya

Board Regular
Joined
Nov 5, 2009
Messages
93
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
?
 

Watch MrExcel Video

Forum statistics

Threads
1,095,933
Messages
5,447,390
Members
405,450
Latest member
JamesLH

This Week's Hot Topics

Top