I have got a command button on one of the excel sheet to hide/unhide one of the worksheet. See below code.
However, now I want to add a capability for the admin to enter the password in order to unhide the sheet, else anyone can click the button and unhide the data sheet.
Is there a way to force excel to show the normal enter password prompt to unhide?
Thanks
Sub myButton()
ActiveWorkbook.Unprotect
If (Sheets("Sheet2").Visible) Then
Sheets("Sheet2").Visible = False
Sheets("Sheet1").Select
Else
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Select
End If
ActiveWorkbook.Protect Password:="password", structure:=True, Windows:=False
End Sub
You can use an inputbox to collect input from a user. Not exactly sure what you are trying to do, but maybe something like this works.