Hide/Unhide worksheets tied to button w/password

Blackcloud_9

New Member
Joined
Jun 11, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have an automated spreadsheet. I need to hide/unhide a couple of worksheets (named "Minitab Output" & "Configurations") through a macro.

The trick is I want to tie the macro to a button that when clicked will require a password to continue.
Also I would like it work in either direction...
Example:
Click button > Password > Unhide worksheets
Click button > Password > Hide worksheets

Thanks in advance
Let me know if you need anymore info

Balackcloud_9
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Change the password "Secret" to suit.

VBA Code:
Sub Button1_Click()
    Dim strPW As String
    strPW = Application.InputBox("The password is...", "Toggle Sheets Visible", Type:=2)
    If strPW = "False" Then Exit Sub 'User canceled
    If strPW = "Secret" Then
        Sheets("Minitab Output").Visible = Not Sheets("Minitab Output").Visible
        Sheets("Configurations").Visible = Not Sheets("Configurations").Visible
    Else
        MsgBox strPW, vbExclamation, "Invalid Password"
    End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,939
Latest member
Leon Leenders

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