+ Reply to Thread
Results 1 to 2 of 2

Require to give two password in one workbook for different sheets

Hybrid View

shvjmali Require to give two password... 04-26-2013, 02:46 AM
:) Sixthsense :) Re: Require to give two... 04-27-2013, 03:23 AM
  1. #1
    Registered User
    Join Date
    04-26-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1

    Red face Require to give two password in one workbook for different sheets

    I have coded excel sheet & along with its different sheets with password.

    same workbook is accessed by 2 types of user

    so want to again lock particular sheet by second password via vba code

    my first code is playing date wise lock as follow

    Worksheets("Daily_Activity").Activate
    ActiveSheet.Unprotect "123456"
    i = Application.WorksheetFunction.CountA(Range("3:3"))
    Range("d3").Select
    For n = 1 To i - 2
    If ActiveCell.Value < Date Then
    ActiveCell.EntireColumn.Locked = True
    ActiveCell.Offset(0, 1).Select
    Else
    ActiveCell.Offset(0, 0).Select
    ActiveCell.EntireColumn.Locked = False
    ActiveCell.Offset(0, 1).Select
    End If
    Next
    ActiveSheet.Protect "123546", AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowInsertingHyperlinks:=True

    now i want to add second password to "Daily_Activity" sheet which already have the password as "123456" please help me to lock same with second password

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Require to give two password in one workbook for different sheets

    No you cant give two password for protecting or unprotecting the sheet. Instead just have a hidden password which the users won't know and try to code like this...

    In the below mypassword is the original sheet password and User1 and User5 is the masking password which you can give it to the users. Use an If statement to verify the masking password and assign the right password to unprotect the worksheet. So that the Users wont know the real password.

    Use a text box on form to enter the password because you can mask the password text with a * when users type the password by giving * in PasswordChar property

    Dim sEnteredPwD As String
    sEnteredPwD = InputBox("Enter Your Password to Proceed", "Enter Password")
    If sEnteredPwD = "User1" Or sEnteredPwD = "User5" Then sEnteredPwD = "mypassword"
    ActiveSheet.Unprotect sEnteredPwD


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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