VB Code to "Unfilter" Spreadsheet

golf4

Active Member
Joined
Jul 8, 2002
Messages
452
Hi everyone -

It's been a while since the last time I posted and hope everybody had a happy and safe New Year.

A quick issue came up at work that I'm looking for a little imput on: I created a sizable spreadsheet that tracks our vacant housing units from the time the tenant moves out all the way through getting the made-ready unit back from our Maintenance Department.

The spreadsheet has quite a few columns, i.e. Vacate Date, Back from Maintenance Date, Re-Rented Date, etc. In an effort to make the spreadsheet more usable, I have also turned on the Auto-Filter for all of the columns. What we have been running into is that employees will filter a column and then save the spreadsheet with the filtered column still on. Then, when someone else pulls up the the spreadsheet, and they are not familiar with Auto-Filter, they don't know they are not seeing all of the data.

I was hoping someone could help me with code that would turn off the filtering but not necessarily the Auto-Filter anytime the spreadsheet is saved and closed. This should, hopefully, correct the problem.

Thanks,

Golf
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi golf,
This should "unfilter" any columns (between A and Z) left filtered and return these columns to be ready for filtering, and will happen before any saves of the workbook. (Whether it gets closed or not.)
(Just change the columns to which ones you want.)
Gets entered into the ThisWorkbook module.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Columns("A:Z").AutoFilter
Columns("A:Z").AutoFilter
End Sub

You could also change this to a Before Close instead of Before Save...

This help?
Dan
 
Upvote 0
Hi, Dan -

Thanks so much for the response and the help --- works like a charm!!!

Hope things are goin good for ya in the Last Frontier.......

Thanks again,

Golf
 
Upvote 0
Hi Golf,

FIY, Here is another way...to unfilter ranges.

Code:
ActiveSheet.AutoFilterMode = False
 
Upvote 0
Most welcome, though I gotta say I would use what Colo suggests.
Using (for example)

ActiveSheet.AutoFilterMode = False
Columns("A:Z").AutoFilter

will be much more reliable with vastly more predictable results than my earlier suggestion.

(And yes. The snow's getting deeper as I write this, but things are going pretty good up here. Been a beautiful winter so far.)
Dan
 
Upvote 0

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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