Protecting Worksheets and hiding based on password

  • Thread starter Thread starter bdunk
  • Start date Start date
B

bdunk

I did a search on this and got close but not exactly what I was lookin
for. I would like to password protect worksheets within a workbook.
would like the password window to open upon opening the workbook, th
user would enter their password, then the appropriate sheets would b
displayed. Is this possible? I have 3 sheets each for an individua
user and a chart that graphically charts the three users progress. S
when user one opens the workbook they enter their password and se
their worksheet only and so on for all the other users.


Thanks Bdun
 
Hi
you could achieve this using the workbook_open event, asking for a
password and unhiding the worksheets.
In addition put some code in the workbook_close event to hide the
sheets again and to save the workbook. For event procedures see:
http://www.cpearson.com/excel/events.htm
 
Yes, however what would the code look like to perform something lik
this? I am a newbie to VB in excel so the more help hte better.

Thank
 
Hi
if you really are new to VB I'm not sure you want to go this way :-)

not tested but put the following two procedures as starting point in
your workbook module (not in a standard module)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Worksheets("sheet1").Visible = False
Application.EnableEvents = False
Me.Save
Application.EnableEvents = True
End Sub

Private Sub Workbook_Open()
Dim ret_password

ret_password = InputBox("Enter your password")
If ret_password = "your_password" Then
Me.Worksheets("sheet1").Visible = True
Else
MsgBox "Wrong password"
Me.Close
End If
End Sub
 

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

Back
Top