Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Showing all in Filter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Timmy Mac1 - 21 Feb 2006 12:00 GMT
Apologies in advance because I know this is probably quite basic stuff
here...

I want to get a macro that releases all filters in all worksheets, but
I don't know how to get around the fact that a filter might not be
showing or set up for a particular sheet.

I'd appreciate any help to construct the necessary statement to get
around this.

thanks

tt

Signature

Timmy Mac1

Dave Ramage - 21 Feb 2006 13:28 GMT
Each worksheet has two properties that will be of use here- FilterMode and
AutoFilterMode. The first of these indicates whether any rows are hidden by a
filter (either AutoFilter or Advanced Filter), the second indicates whether
the AutoFilter mode is active for a sheet, but will still = TRUE if all rows
are visible (i.e. AutoFilterMode only indicates whether the AutoFilter
dropdowns are visible on a worksheet). Note also that FilterMode is read
only, whereas AutoFilterMode is read/write (and can therefore be used to turn
off autofilter mode).

There is also a handy worksheet method ShowAllData, which will make all rows
visible, but will not remove the AutoFilter dropdowns. This method will raise
an error if there are no hidden rows.

Put all this together and you get something like this:
Sub RemoveAllFilters()
   Dim ws As Worksheet
   
   For Each ws In ActiveWorkbook.Worksheets
       If ws.FilterMode Then
           ws.ShowAllData
       End If
       ws.AutoFilterMode = False
   Next ws
End Sub

Cheers
Dave

> Apologies in advance because I know this is probably quite basic stuff
> here...
[quoted text clipped - 9 lines]
>
> tt
Tom Ogilvy - 21 Feb 2006 13:52 GMT
Sub bbb()
For Each sh In Worksheets
 If sh.FilterMode Then
   sh.ShowAllData
 End If
Next
End Sub

is possibly what you want.

Signature

Regards,
Tom Ogilvy

> Apologies in advance because I know this is probably quite basic stuff
> here...
[quoted text clipped - 9 lines]
>
> tt
Timmy Mac1 - 21 Feb 2006 14:36 GMT
Tom, Dave

Many thanks for your helpful responses :)

cheers

t
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.