What is the trigger for password protecting a worksheet.

USAMax

Well-known Member
Joined
May 31, 2006
Messages
843
Office Version
  1. 365
Platform
  1. Windows
I have worksheet one that I want to be read only for everyone but the second worksheet is superfluous I need to hide it. I password protect the first sheet everyday and I would like to know the code that will detect when the sheet is protected so it can hide the second sheet and when the first sheet is unprotected I want to unhide the second worksheet.

I can code most of what I need but I cannot find the code to detect the password trigger.

Thanks,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Why don't you hide it when you do the password protect?
Write a little macro :
Code:
Sub ProtectSheet()
    Dim sPW1 As String, sPW2 As String
   
    Do
        sPW1 = InputBox("Protect Password Please", "Protect Sheet1")
        sPW2 = InputBox("Repeat Password Please", "Protect Sheet1")
    While sPW2 <> sPW1
    
    Sheet1.Protect Password:=sPW1
    Sheet2.Visible = xlSheetHidden
   
End Sub
 
Upvote 0
Thank you sijpie, I probably would have thought of something like this but actually I am doing this for someone who has been protecting his worksheet for many years and I didn't want to disrupt his routine. He is use to the standard way of password protecting his worksheet and I thought there might be a trigger to detect when he is protecting the worksheet so I could hid the worksheet and unhide the other worksheet when he removes the password protection.

Thank you again,
 
Upvote 0
Why don't you hide it when you do the password protect?
Write a little macro :
Code:
Sub ProtectSheet()
    Dim sPW1 As String, sPW2 As String
   
    Do
        sPW1 = InputBox("Protect Password Please", "Protect Sheet1")
        sPW2 = InputBox("Repeat Password Please", "Protect Sheet1")
    Loop While sPW2 <> sPW1
    
    Sheet1.Protect Password:=sPW1
    Sheet2.Visible = xlSheetHidden
   
End Sub

Hey Sijpie, it looks like your idea was a success. I did not think they would like the idea but as it was the only option I presented it and they liked it.

Thank you,
 
Upvote 0

Forum statistics

Threads
1,215,548
Messages
6,125,472
Members
449,231
Latest member
Sham Yousaf

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