Ok, I worked out how my psuedocode would be written and have tested it
out on a basic sheet, and it does work. Here's what happens with my
code.
There is a button on a menu page called "Hide" and one called "Show"
You click Hide, and a box pops up asking you for a sheet name, and a
password. You type in the sheet name, and the password, and click ok.
The sheet then becomes hidden, and protected by the password you
typed.
Click "Unhide" and it shows what looks like the same box, bar it says
"Show". You type in a sheet name, and a password. This time, it unlocks
the workbook with the password you provided, and then makes the sheet
visible.
So, here's the code, for those interested.
UserForm1
Global Definitions
Dim formhidename As String
Dim passwordvalue As String
Private Sub CommandButton1_Click() 'ok button
formhidename = TextBox2.Text
passwordvalue = TextBox1.Text
Sheets(formhidename).Visible = False
ActiveWorkbook.Protect (passwordvalue)
End
End Sub
Private Sub CommandButton2_Click() ' cancel button
End
End Sub
UserForm2
Global Definitions
Dim formunhidename As String
Dim newpasswordvalue As String
Private Sub CommandButton1_Click() 'ok button
formunhidename = TextBox2.Text
newpasswordvalue = TextBox1.Text
ActiveWorkbook.Unprotect (newpasswordvalue)
Sheets(formunhidename).Visible = True
End
End Sub
Private Sub CommandButton2_Click() ' cancel button
End
End Sub
Limitations. It will only allow one sheet to be hidden before locking
the workbook.
*thinks*
Ooh, I know. Make it so that at the beginning of the code it checks if
the workbook is protected, then unlocks if nessecary, hides the sheet,
then relocks it. Will post solution later.
-Bob