Autofilter Macro

pagrender

Well-known Member
Joined
Sep 3, 2008
Messages
652
Hello,

I have a macro that shows all the data hidden by an autofilter. This macro works fine when there is at least one item that has been filter. Whenever I try to run this macro without an item being filtered, I get an error. Is there a way to set up an IF statement to say if there is a filter present, run the macro; else ignore the macro? I've attached the macro below.

Thanks!

Sheets("Summary").Select
ActiveSheet.Unprotect
'
ActiveSheet.ShowAllData
Range("A3").Select

Sheets("Summary").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFiltering:=True
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Given that's the only issue you face perhaps just including the line

Code:
On Error Resume Next
Sheets("Summary").Unprotect
ActiveSheet.ShowAllData
Sheets("Summary").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFiltering:=True

And you don't need to select everything ;)

HTH


Dave
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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