Password protection

Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Password protection

  1. #1
    New Member
    Join Date
    Jul 2002
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Password protection

     
    I am trying to create a vba that will enable me to have one user enter a password and work in a particular cell and have a second user enter a password to edit a second cell. Any ideas. [/code]

  2. #2
    New Member
    Join Date
    Jul 2002
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection


    I will expand on my question. I would like for the sheet to be protected until a password is entered by a particular person to edit a cell and then reprotect the cell once they get out of the worksheet. I would need this for two different persons with different passwords.

    Thank you

  3. #3
    MrExcel MVP TommyGun's Avatar
    Join Date
    Dec 2002
    Location
    Clear Lake, TX
    Posts
    4,202
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    Right-Click on the Sheet tab that you want to protect, and select view code. Delete the code that is placed by default and insert this. Change to your needs....

    Private Sub Worksheet_Activate()

    Dim s As String

    Const SheetPass = "protect"
    Const Pass1 = "test"
    Const Pass2 = "this"

    Me.Protect Password:=SheetPass, DrawingObjects:=True, Contents:=True, _
    Scenarios:=True, UserInterfaceOnly:=True

    s = InputBox("Please input your password.", "Password Input")

    If s <> vbNullString Then

    If s = Pass1 Then
    Me.[A1].Locked = False
    ElseIf s = Pass2 Then
    Me.[A2].Locked = False
    End If

    End If

    End Sub

    Private Sub Worksheet_Deactivate()

    Me.[A1].Locked = True
    Me.[A2].Locked = True

    End Sub

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Perth Australia
    Posts
    1,579
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    Hi there

    Another alternative, (not as sophisticated), which only allows a value change in a specific cell. Works on the doubleclick event macro (after pasting into the vb editor for the sheet, the password prompt is activated by doubleclicking any cell.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    answer = InputBox("Enter Password", "PASSWORD PROTECTED")
    If answer = "password1" Then
    ActiveSheet.Unprotect "password3"
    [G4].Value = InputBox("enter new value for cell G4", "CHANGE VALUE IN G4")
    ActiveSheet.Protect "password3"
    Else
    If answer = "password2" Then
    ActiveSheet.Unprotect "password3"
    [G4].Value = InputBox("enter new value for cell G4", "CHANGE VALUE IN G4")
    ActiveSheet.Protect "password3"
    Else
    ActiveSheet.Protect "password3"
    Exit Sub
    End If
    End If
    End Sub


    regards
    Derek

  5. #5
    New Member
    Join Date
    Jul 2002
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection



    Tommygun - which codes are you referring to when you say to delete the default codes. I could not get the code to work for me yet.

    Derek - Where do you set the passwords to get into the cell. I tried your code out and anything that I typed in for the password seemed to work?

    Thank you to both....


  6. #6
    MrExcel MVP TommyGun's Avatar
    Join Date
    Dec 2002
    Location
    Clear Lake, TX
    Posts
    4,202
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    The code should go on the Worksheet object (ie Sheet1). How is the code not working???

  7. #7
    New Member
    Join Date
    Jul 2002
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    I am not getting a password prompt for cells a1 or a2 and if I am understanding the code correctly there is not an input box coming up either. I am free to type anything in the two cells.

  8. #8
    MrExcel MVP TommyGun's Avatar
    Join Date
    Dec 2002
    Location
    Clear Lake, TX
    Posts
    4,202
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    Where did you place the code?

  9. #9
    New Member
    Join Date
    Jul 2002
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

    I placed the code at the beginning of sheet 1 codes.

  10. #10
    MrExcel MVP TommyGun's Avatar
    Join Date
    Dec 2002
    Location
    Clear Lake, TX
    Posts
    4,202
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Password protection

      
    Okay, I will email you a sample.

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
  •  

 

 
DMCA.com