VBA to Remove filters AND Allow Filtering

KatKitKat

New Member
Joined
Apr 27, 2022
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have an issue I can't figure out. I have a spreadsheet with several control buttons that run VBA macros to filter the spreadsheet based on criteria. I also have code in the last line to AllowFiltering (spreadsheet is password protected and we want to allow users to utilize other filtering options).

I added a control button to remove any filters created by the control buttons and added the code to AllowFiltering to this new button but it is not working (the Allow Filtering options). Does anyone have any idea why? This same code (last line below that applies password) works on every other button I have added, but not for this one, so I imagine I have something incorrect. My code is below.

Any help would be appreciated.
Thanks! Kat

VBA Code:
Sub ClearFilters_Click()
ActiveSheet.Unprotect Password:="1234"
Sheets("CMLog").AutoFilterMode = False
ThisWorkbook.RefreshAll
Range("E4") = ("ALL")
Range("H4") = ("ALL")
Range("M4") = ("ALL")
ActiveSheet.Protect Password:="1234", AllowFiltering:=True
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try replacing this line
VBA Code:
Sheets("CMLog").AutoFilterMode = False
with
VBA Code:
Sheets("CMLog").ShowAllData
 
Upvote 0
Try replacing this line
VBA Code:
Sheets("CMLog").AutoFilterMode = False
with
VBA Code:
Sheets("CMLog").ShowAllData
That did it! Thank you so much for saving me from hours of trying to figure it out!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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