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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,415
Messages
6,119,377
Members
448,888
Latest member
Arle8907

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