Auto Filter Mode - Show all

prasath

Board Regular
Joined
Dec 11, 2009
Messages
57
In one of my macro, i am struggling debug with autofilter option. If the sheets are filtered, the macro is not working.

For this,

When i run the macro, it should check "If any data is filtered by Autofilter mode, if so, it should free it (show all)"

Note : I prefer this auto filter check should be done in the all the worksheets of active workbook.

Or, if there has been a better way, guide me..

Thanks in advance

Prasath RH
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
The line

ActiveSheet.AutoFilterMode = False

should take care of that, if you place it in your macro at the point where you don't want errors to occur. No error bypasses or error handlers are needed.
 
Upvote 0
If you are going to use ActiveSheet.ShowAllData, enclose it in an error bypass in case the sheet is not in Filter mode.

On Error Resume Next
ActiveSheet.ShowAllData
Err.Clear
 
Upvote 0
The line

ActiveSheet.AutoFilterMode = False

should take care of that, if you place it in your macro at the point where you don't want errors to occur. No error bypasses or error handlers are needed.
Thanks for your reply. .

I would like to add this check point for all my worksheets in the active workbook.. How to do that..
 
Upvote 0
Your last question is not clear. If this is for an existing macro and you are looping through worksheets, this example might be what you are asking about:

Code:
Dim ws as Worksheet
For each ws in Worksheets
On Error Resume Next
ws.ShowAllData
Err.Clear 
Next ws
 
Upvote 0
Tom,

How could I imbed this in a worksheet to make sure the filters were cleared upon exiting or opening the worksheet? We have worksheet shared by a group. Some members complain of missing data not realizing that filtering is on from the last team member. Ideas?
 
Upvote 0
What you could do is, each time the workbook opens, you can undo any filters on any sheets with this code in the workbook module:

Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In Worksheets
On Error Resume Next
ws.ShowAllData
Err.Clear
Next ws
Application.ScreenUpdating = True
End Sub

Remember, that's the *Workbook* module. To locate it:
- from your worksheet press Alt+F11
- press Ctrl+R
- Find the workbook name in the Project window (vertical pane on the left), and expand its yellow folder named Microsoft Excel Objects.
- Find the object named ThisWorkbook, right click on it, select View Code, and paste the above code into the large white pane that is the workbook module.

Press Alt+Q to return to the worksheets.

Press Ctrl+S to save the workbook.

Now whenever the workbook closes and is reopened, no sheets will be filtered.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top