Sh.Protect UserInterFaceOnly problem

Dedeke

Board Regular
Joined
Dec 1, 2020
Messages
70
Office Version
  1. 2016
Platform
  1. Windows
Hello,
Have been reading about UserInterfaceOnly in this forum but did not find a solution.

Having this problem using the code as followed:
Having multiple sheets protected with the same password.
When opening the workbook it demands the password for each sheet wich is protected.
After canceling the input for the passwords, so they stay protected, the code seems to work.

So when i delete the code from the workbook, on startup it does not show any popups to enter password.
Any idea why this happens. And maybe a solution.

VBA Code:
Private Sub Workbook_Open()

Dim Sh As Worksheet

    For Each Sh In Worksheets
       Sh.Protect UserInterFaceOnly:=True
    Next
    
End Sub

Thx getting into this
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Sorry , my bad.
Found the solution,like always, on this forum.


VBA Code:
Private Sub Workbook_Open()
    Dim ws As Worksheet
 
    For Each ws In ThisWorkbook.Worksheets
        ws.Protect UserInterfaceOnly:=True, Password:="1234"
    Next ws
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,534
Messages
6,125,372
Members
449,221
Latest member
chriscavsib

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