Power Query Course in Spanish
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Password protect a sheet

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a system to be used by many and there is one sheet where i only want people that know a password to be able to see it, is there a way that when someone clicks the sheet tab or a linking password that they are asked for a password???

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Any One?????

  3. #3
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-29 02:08, jamienwood wrote:
    I have a system to be used by many and there is one sheet where i only want people that know a password to be able to see it, is there a way that when someone clicks the sheet tab or a linking password that they are asked for a password???
    Place code in the Thisworkbook object;
    Notes
    1) Change sPwd const to your password
    2) Change the Sh.Name = "Sheet3" to your
    sheet name that you want password protected.


    '// Change to your password
    Const sPwd As String = "mypassword"
    Dim LastSheet

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim OK As String
    If Sh.Name = "Sheet3" Then
    OK = InputBox("Please enter password", "Sheet Sentry")
    If OK <> sPwd Then Sheets(LastSheet).Activate
    End If
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    LastSheet = Sh.Name
    End Sub


    Kind Regards,
    Ivan F Moala From the City of Sails

  4. #4
    New Member
    Join Date
    Mar 2002
    Location
    Paul
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What syntax would I use to employ the PasswordChar function on this example?

    TIA

    Cheers - Paul

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    i have but this code into VBA but it doesnt seem to do anything, maybe it me but does anyone know how to make it work??

  6. #6
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am also using 2000 if that makes any difference,Any one, Please

  7. #7
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Christchurch New Zealand
    Posts
    1,030
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    put the code in the worksheet that you want the user asked for the password not in a module.

  8. #8
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    i have tried putting this code onto the sheet code but it still doesnt do anything is it meant to ask for the password when i click on the page or is anymore code needed??

  9. #9
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-30 01:06, jamienwood wrote:
    i have tried putting this code onto the sheet code but it still doesnt do anything is it meant to ask for the password when i click on the page or is anymore code needed??
    Put the code into the Thisworkbook object
    and Not the sheets code module as I specified
    See if this works.
    Also note the other Notes i made
    Good luck
    Kind Regards,
    Ivan F Moala From the City of Sails

  10. #10
    Board Regular
    Join Date
    Apr 2002
    Location
    Manchester UK
    Posts
    133
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    i have got the message box to pop up, but even though i have changed the password like you said when you enter the password and click ok you are taken back to your last sheet and if you press cancel it lets you in???

    just to check this is what i changed the code to:
    '// Change to your password
    Const user12 As String = "mypassword"
    Dim LastSheet

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim OK As String
    If Sh.Name = "Passworded" Then
    OK = InputBox("Please enter password", "Sheet Sentry")
    If OK <> user12 Then Sheets(LastSheet).Activate
    End If
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    LastSheet = Sh.Name
    End Sub


Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •