Solved

How to determine if an Excel Table filter is on or off

Posted on 2013-11-09
3
436 Views
Last Modified: 2013-11-09
I have a Command Button to Update a table connected to an Access Query.  Sometimes the table is filtered and sometimes it is not.

Currently my VBA code looks like this:

Sheets("MeditechData").Select
ActiveSheet.ShowAllData
Selection.AutoFilter
Range("C1").Select
ActiveWorkbook.RefreshAll

If the filter has been turned on this works fine.  However, if the table is not filtered, I get the error :

ShowAllData method of Worksheet class failed.

Is there a way I can set up a check to see if the table is filtered or not?

Thanks

Glen
0
Comment
Question by:GPSPOW
3 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 39636160
Hi,

pls try

If Not ActiveSheet.AutoFilter Is Nothing Then
 ' your code
End If

Open in new window

Regards
0
 
LVL 2

Accepted Solution

by:
mensmaximus earned 500 total points
ID: 39636172
Try something like

If Not ActiveSheet.AutoFilterMode Then
    ActiveSheet.Range("c1").AutoFilter
End If

Open in new window

0
 

Author Closing Comment

by:GPSPOW
ID: 39636198
Thanks

I added your lines to my code and it worked.

glen
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question