safeguarding document

D

dieter

How can I make a document disappear and reopen in EXEL only after using a
password?
 
G

Gord Dibben

Save it with a password to open.

To make it diasappear, close it.

Then re-open it using the password to open.


Gord Dibben MS Excel MVP
 
R

ryguy7272

That was supposed to be for another post! How did that get in there!!!
Anyway.....

Put the code below behind the sheet (right-click tab and click 'view code')

Private Sub CommandButton1_Click()

Dim i_pwd As String

i_pwd = InputBox("Please Enter Password to Unhide Sheet", "Unhide Sheet...")
If i_pwd = "" Then
Exit Sub
End If

'#1
Select Case LCase(i_pwd)
Case Is = "#1"
Worksheets("#1").Visible = True
Sheets("#1").Select

'#2
Case Is = "#2"
Worksheets("#2").Visible = True
Sheets("#2").Select

'#3
Case Is = "#3"
Worksheets("#3").Visible = True
Sheets("#3").Select

'#4
Case Is = "#4"
Worksheets("#4").Visible = True
Sheets("#4").Select

Case Else
MsgBox "Incorrect password; no action taken.", vbInformation, _
"Unhide Sheet..."
End Select

Exit Sub


End Sub


Put this code in the 'ThisWorkbook' file:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call HideSheets
End Sub

Private Sub Workbook_Open()
Worksheets("AllEmployees").Activate
Application.GoTo Range("A1"), Scroll:=True

End Sub

Obviously, you have to change the code to match your sheet names.

HTH,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top