Controlling auto-filter with VBA

D

Dallman Ross

I have a question about controlling auto-filter with VBA and
need some help. I hope someone will oblige.

I know about Debra Dalgleish's excellent and very helpful
pages at http://www.contextures.com -- and specifically
the pages to do with auto-filters here:
http://www.contextures.com/xlautofilter03.html#All

But I still am having a problem with Excel XP/2002.

Specifically, when I use the suggested code

Sub ShowAllRecords()
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
End Sub

if FilterMode was on but all data is already being shown,
I get an error message when I run the macro.

I can think of at least three ways to work around the issue.
But I'd like to know the suggested solution.

What I'm doing right now is (1) checking for
 
D

Don Guillett

I have a question about controlling auto-filter with VBA and
need some help. I hope someone will oblige.

I know about Debra Dalgleish's excellent and very helpful
pages at http://www.contextures.com -- and specifically
the pages to do with auto-filters here:
http://www.contextures.com/xlautofilter03.html#All

But I still am having a problem with Excel XP/2002.

Specifically, when I use the suggested code

Sub ShowAllRecords()
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
End Sub

if FilterMode was on but all data is already being shown,
I get an error message when I run the macro.

I can think of at least three ways to work around the issue.
But I'd like to know the suggested solution.

What I'm doing right now is (1) checking for

try
Sub showall()
On Error GoTo away
ActiveSheet.ShowAllData
away:
End Sub
 

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