Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 02-09-2010, 03:09 PM
Rachel Thomas Rachel Thomas is offline
Registered User
 
Join Date: 09 Feb 2010
Location: Honolulu, HI
MS Office Version:Excel 2003
Posts: 1
Rachel Thomas is becoming part of the community
Multiple passwords in single spreadsheet

Please Register to Remove these Ads

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
Reply With Quote
  #2  
Old 02-09-2010, 04:49 PM
ChemistB ChemistB is offline
Forum Guru
 
Join Date: 05 Aug 2004
Location: NJ
MS Office Version:MS 2007
Posts: 2,600
ChemistB is attaining expert status ChemistB is attaining expert status
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
Code:
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.
Code:
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
File Type: xls multiplepasswords1.xls (34.5 KB, 0 views)
__________________
ChemistB
My 2¢
Reply With Quote
  #3  
Old 02-09-2010, 04:52 PM
dominicb's Avatar
dominicb dominicb is offline
Forum Moderator
 
Join Date: 25 Jan 2005
Location: Lancashire, England
MS Office Version:MS Office 2000, 2003 & 2007
Posts: 3,310
dominicb has an addiction to Excel
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
__________________
Now available : Ultimate Add-In 2007
Integrates directly into the Office Excel Ribbon


Download Ultimate Add-In v1.52 from www.dom-and-lis.co.uk
90+ Utilities, 200+ Sub utilities last updated 25th April 2008
Free!!
Reply With Quote
  #4  
Old 02-09-2010, 04:55 PM
ChemistB ChemistB is offline
Forum Guru
 
Join Date: 05 Aug 2004
Location: NJ
MS Office Version:MS 2007
Posts: 2,600
ChemistB is attaining expert status ChemistB is attaining expert status
Re: Multiple passwords in single spreadsheet

:::slapping forehead::: Going from Excel 2000 directly to 2007, I forgot that 2003 had that capability. My bad.
__________________
ChemistB
My 2¢
Reply With Quote
  #5  
Old 02-09-2010, 05:55 PM
dominicb's Avatar
dominicb dominicb is offline
Forum Moderator
 
Join Date: 25 Jan 2005
Location: Lancashire, England
MS Office Version:MS Office 2000, 2003 & 2007
Posts: 3,310
dominicb has an addiction to Excel
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
__________________
Now available : Ultimate Add-In 2007
Integrates directly into the Office Excel Ribbon


Download Ultimate Add-In v1.52 from www.dom-and-lis.co.uk
90+ Utilities, 200+ Sub utilities last updated 25th April 2008
Free!!
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump