Turn AutoFilter off by code?

E

Ed

I'm trying to turn off the AutoFilter in a macro using the following code:
ActiveSheet.Select
Sheet1.AutoFilterMode = False

Of course, the reason I'm posting is that it doesn't work. It's stored in
my Personal.xls, and needs to be used on the spreadsheets I create (I use a
certain template that will always have the information to be filtered on
Sheet1). Any help is appreciated.

Ed
 
J

JohnI in Brisbane

Ed,

ActiveSheet.AutoFilterMode = False

or

Worksheets("Sheet1").AutoFilterMode = False

regards,

JohnI
 
S

steve

Ed,

Try using:

ActiveSheet.AutoFilterMode = False

or
Sheets("Sheet1").AutoFilterMode = False

(Your code is looking for Sheet1 where Sheet1 is defined as Worksheet.)
Surprised you are not getting an error message...
 
E

Ed

Steve - that did it! Thank you. I used the sescond one, and it did the
job.

I *was* getting an error code, but nothing I tried would work.

So my code was looking for 'Sheet number 1' instead of 'Sheet named "Sheet1"
' I'll have to remember that *little* detail. 8>/

Ed
 
S

steve

Ed,

Just another of those things to keep straight when working with code...

Very glad that it worked!!!
 
D

Don Guillett

If you want to keep it but restore the "before filter" try
Sub ShowAll()
On Error GoTo away
ActiveSheet.ShowAllData
away:
End Sub
 
Top