Solved

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

Posted on 2013-11-09
3
423 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 49

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now