Protected Sheets - Show All Data

Foz1980

Board Regular
Joined
May 6, 2015
Messages
128
Hi All,

I use the below code for a few workbooks that my department uses, this unfilters the worksheets on opening. This was needed as some shared users were being annoying and saving the documents with columns filtered.

Code:
Private Sub Workbook_Open()
    Dim sh As Variant
    For Each sh In Worksheets
      If sh.FilterMode Then sh.ShowAllData
    Next
End Sub

However, I now also need to apply this to a shared and protected workbook.
I have tried adding ActiveSheet.Unprotect at the start and ActiveSheet.Protect at the end to remove the protection but it isn't working.

Can anyone help please?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
did the person protecting it use a password

also activesheet might be the issue if it is not working where you expect it to
 
Upvote 0
did the person protecting it use a password

also activesheet might be the issue if it is not working where you expect it to

Yes it is password protected. I know the password, just don't know the code needed to get to the point where a password can be used.
 
Upvote 0
Upvote 0
sorry, I missed the "SHARED" excel part, I don't know a way to circumvent (I guess it is possible somehow)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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