prompt for password to open different sheets

SimonPerry

New Member
Joined
Jun 10, 2006
Messages
47
Hi all,

I want to lock down access to multiple sheets within my workbook all of which are accessed by a front home page.

I want to assign different paswords to each of the sheets to be accessed; any ideas how I can do this?

I managed to get this working from a piece of copied vba from an excel book I have however this only works for the one single sheet. :( I would copy and paste the vba thus far however I'm typing this on my blackberry as I don't currently have any internet access here.

Thanks loads if anyone can save me on this one...
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello,
To assign different passwords to worksheets insert this to each worksheet code changing the password as you wish (in this example the password is "alpha":
Code:
 Private Sub Worksheet_Activate()
    Cells.Select
    Selection.EntireRow.Hidden = True
    P = InputBox("enter password")
    If P = "alpha" Then
    Cells.Select
    Selection.EntireRow.Hidden = False
   
    ElseIf P <> "alpha" Then
    MsgBox "That password is incorrect, taking you to Sheet1"
    
    Sheets("Sheet1").Select
    
      End If
End Sub


Private Sub Worksheet_Deactivate()
    Me.Cells.EntireRow.Hidden = True
End Sub
Hope this helps
 
Upvote 0
If you PM me your e-mail address I'll send you a workbook that lets you assign sheet access and passwords to individual users. I can also send one that assigns level passwords without user names. Both have dashboard interfaces.

Note that I'll be offsite until Sunday and might not respond right away.
 
Upvote 0
Thank you both so much. I will try the code suggested shortly and then let you know how I get on.

I'll also pm you Smitty as would love to see the example workbooks you mentioned.

Thanks again
Simon
 
Upvote 0
Ndedrino's - hi again. Can you explain the very bottom bit of code for me? I get the bulk bit of code but this bottom part of me.cells is confusing me...

Thanks again
 
Upvote 0
Hello Simon,
There are several ways to write the code and this particular coder decided to use the "Me.Cells"
Instead he could have written it like this :
Code:
 Private Sub Worksheet_Deactivate()
Cells.Select
    Selection.EntireRow.Hidden = True
End sub

The gist is that upon deactivation of the worksheet all cells are hidden so that next time when the operator clicks on that tab he cannot see what's on the sheet unless the proper password is entered and all cells become visible.
 
Upvote 0
hi i appreciate this is a very old thread but the line of code Selection.EntireRow.Hidden = True gives me a run time error.

can anyone please advise?
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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
Back
Top