+ Reply to Thread
Results 1 to 5 of 5

Multiple passwords in single spreadsheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-09-2010
    Location
    Honolulu, HI
    MS-Off Ver
    Excel 2003
    Posts
    1

    Multiple passwords in single spreadsheet

    Hi,
    Question: I have one excel workbook (2003) that is accessed by three people. I'd like each person to have a different password to the same sheet.

    For example, person 1 can update columns A-D, person 2 can update columns E-G and person 3 can update columns H-J. Is it possible to have three passwords on the same spreadsheet?
    Thank you!

    Rachel

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Multiple passwords in single spreadsheet

    This would require VBA. I'm just beginning to learn VBA but here's what I came up with. You will need to secure your VBA code to prevent people from looking at the code where other people's passwords will be seen. One of the VBA gurus here might improve on this code. You''ll need a subroutine that runs on opening the workbook (to unprotect specific columns) and one to work on saving (to reprotect those columns). These routines should be pasted in "Thisworkbook". Right click on a tab and "view code" to open the vba editor and then double click on thisworkbook to open that code window. In my example, I did not protect the code so you can view it.
    I chose Jim, Lynn, and Bob with passwords JimsPassword, LynnsPassword and BobsPassword. The sheet password is "test_one"
    Routine 1
    Private Sub Workbook_Open()
    
    Dim UserName As String
    Dim Pword As String
    Dim Qualifier As String
    
    Sheets("Sheet1").Select
    
    Application.ScreenUpdating = False
    
    UserName = InputBox("Enter your name")
    Qualifier = InputBox("Enter your password")
    
    Select Case UserName
        Case "Jim"
            If Qualifier = "JimsPassword" Then                  'Replace with Jim's log in password
            ActiveSheet.Unprotect Password:="test_one"           'Replace with the worksheet password
            Columns("A:B").Select
            Selection.Locked = False
            [A1].Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="test_one" 'Replace with the worksheet password
            Else
            MsgBox ("That is the incorrect password. Close the book and try again")
            End If
            
        Case "Lynn"
            If Qualifier = "LynnsPassword" Then           'Replace with Lynn's log in password
            ActiveSheet.Unprotect Password:="test_one"     'Replace with the worksheet password
            Columns("C:D").Select
            Selection.Locked = False
            [A1].Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="test_one"
            Else
            MsgBox ("That is the incorrect password. Close the book and try again")
            End If
        Case "Bob"
            If Qualifier = "BobsPassword" Then                'Replace with Bob's log in password
            ActiveSheet.Unprotect Password:="test_one"
            Columns("E:F").Select
            Selection.Locked = False
            [A1].Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="test_one"
            Else
            MsgBox ("That is the incorrect password. Close the book and try again")
            End If
        Case Else
            MsgBox ("You have view only rights to this spreadsheet")
    
    End Select
    Application.ScreenUpdating = True
    
    End Sub
    Routine 2 (for saving) much shorter.
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
            ActiveSheet.Unprotect Password:="test_one"
            Columns("A:F").Select
            Selection.Locked = True
            [A1].Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="test_one"
    
    End Sub
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Multiple passwords in single spreadsheet

    Good evening Rachel Thomas

    ...and welcome to the forum!!
    Quote Originally Posted by Rachel Thomas View Post
    For example, person 1 can update columns A-D, person 2 can update columns E-G and person 3 can update columns H-J. Is it possible to have three passwords on the same spreadsheet?
    You can do this without resorting to VBA by using Tools > Protection > Allow users to edit ranges.
    You use this facility to define ranges and secure it with a password. You will need to define user A's ranges, with a password, and user B's ranges with another password, and so on. Then invoke protection (Tools > Protect Sheet, without a password) and the users will not be able to edit each others' ranges (unless they have the other password).

    Don't forget the passwords.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Multiple passwords in single spreadsheet

    :::slapping forehead::: Going from Excel 2000 directly to 2007, I forgot that 2003 had that capability. My bad.

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Multiple passwords in single spreadsheet

    Quote Originally Posted by ChemistB View Post
    :::slapping forehead::: Going from Excel 2000 directly to 2007, I forgot that 2003 had that capability. My bad.
    You know ChemistB, that really is no excuse. You gave me my 5th ever rep point for this post, back in July last year ...

    Take care.

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1