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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,434
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
 
Solution

Blackcloud_9

New Member
Joined
Jun 11, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Works like a charm.

Thank you very much for your prompt response
 

Forum statistics

Threads
1,144,680
Messages
5,725,753
Members
422,639
Latest member
i have a question

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
Top