Password for range

tlkman

New Member
Joined
Apr 14, 2010
Messages
5
I have a worksheet that is password protected and I only allow users to select and enter in cells that are unlocked. I want to allow certain users (Managers) to enter a password for a range of cells that would unlock certain cells and allow them to enter into the cells. (it's a worksheet that may require an approval from a Manager, however I only want the Manager to unlock the cells where they would provide their approval. I would then like the cells to lock after they have entered approved or not approved, when they save the file) I hope that made sense.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi welcome to MrExcel

I'm not an expert so I cannot help you with VBA coding.
If you insert a shape onto your sheet and assign the Macro Password to it, you can use something like this code...

Code:
Sub Password()
ActiveSheet.Unprotect "[B]Password1[/B]"
rspn = InputBox("Ak says....Enter Your Password")
Select Case rspn
Case "[B]Password1[/B]"
   'Range("$E$19:$E$40").Locked = True
   Range("$C$4:$D$40").Locked = False
Case "[B]Password2[/B]" ''Someone else
   Range("$C$19:$D$28").Locked = False
   Range("$C$4:$D$15").Locked = True
   Range("$C$32:$D$40").Locked = True
   Range("$J$20:$J$21").Locked = True
Case "[B]Password3[/B]"  ''Another person
   Range("$C$32:$D$40").Locked = False
   Range("$J$20:$J$21").Locked = False
   Range("$C$19:$D$28").Locked = True
   Range("$C$4:$D$28").Locked = True
Case Else: MsgBox "Wrong Password"
End Select
ActiveSheet.Protect "[B]Password1[/B]"
End Sub

This covers various ranges, change to suit your range.
As you can see from the above code some Ranges are Locked (True)
and some are Unlocked (False)

You can change the Passwords to whatever you like, Password1 is the "Master" password.

I hope this helps you a little.

Ak
 
Upvote 0
I may have spoke too soon. What was provided does work, however if you go into the Visual Basic Editor, you will be able to see the passwords. Is there a way to hide the password macro in VB?
 
Upvote 0
Hi,

In VBA click on Tools - VBAProject Properties - Protection

Click Lock Project for Viewing and enter your Password.

Ak
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top