Clear filters on file save

dwood71

New Member
Joined
Apr 20, 2011
Messages
2
I have an Excel file used by a number of people and this file has mutliple filtered columns.

Some people never clear the filters before they save the file, and then the next person in doesn't realize the filter is on and enters data in the wrong place.

How can I set the file to clear all filters on file save?

Thanks.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi and welcome to Mr Excel,

I think you'll need some VBA to achieve this.

Is it just one sheet which is filtered? Does the filtered sheet(s) have Excel Tables, or just an ordinary worksheet Autofilter?
 
Last edited:
Upvote 0
Welcome to the Board!

You could try this:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim r As Range
Set r = ActiveSheet.AutoFilter.Range
r.AutoFilter
r.AutoFilter
End Sub
or maybe even:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveSheet.ShowAllData
End Sub
Not sure if the last one works before Excel 2007 or not?

Note that this only works with the active sheet while closing. So if a filter is not set you might have a problem and need to put in some checks from there to test if there is an autofilter set up on the sheet or not.

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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