Using VBA to Save and Redo Autofiltering Settings

jonathan_wu

New Member
Joined
Aug 8, 2007
Messages
4
I am trying to figure out how to save a worksheet's autofiltering settings and be able to re-create those settings.

I would start off with a spreadsheet with a few Autofilters on. I would like to make a macro that will record the initial Autofilter settings, then the macro would do a bunch of stuff that would need to 'Show All'. After these actions take place, I would like to be able to return to the initial Autofilter settings. I'm not even sure which VBA command should be used for this sort of thing. Can anyone point me in the right direction or provide some kind of assistance?
 
Hello Jonathan,

in the German Forum I received the reply that my macro with freezing panes at the end of the custom_View-code was running without problems.

But the tester informed me that he had problems with freezing panes on a Mac lately.

I don't know whether you are using a Mac, but can't give further hints.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
in the German Forum I received the reply that my macro with freezing panes at the end of the custom_View-code was running without problems.

To illustrate the problem, on a blank worksheet :

- in C3:C4 put the value "a"
- in C5 put the value "b"
- add a filter to column C
- freeze panes at C3
- filter for "b"

Then run this (not on a mac) :-

Code:
Sub custom_View()
'store settings in Custom View:
ActiveWorkbook.CustomViews.Add ViewName:="ImprobableName", _
    PrintSettings:=False, RowColSettings:=True

' here your Code
' show all
[C:C].AutoFilter Field:=1

' Restore settings:
ActiveWorkbook.CustomViews("ImprobableName").Show
ActiveWorkbook.CustomViews("ImprobableName").Delete
Range("C3").Select
ActiveWindow.FreezePanes = True

' show all
[C:C].AutoFilter Field:=1
End Sub
 
Upvote 0
Thanks to everybody for all of the help. This has been a lifesaver. I implemented Peter's solution and it works like a charm.

I really appreciate all of the help. Thanks a ton.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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