Protection

RichardU

Board Regular
Joined
Aug 3, 2007
Messages
98
How can you set a worksheet up to be protected when a user opens it but still allow a seperate macro to edit protected cells?

Like protect the sheet on open and unprotect before close?

Any other suggestions
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

DiscoPistol

Active Member
Joined
Jun 6, 2006
Messages
261
If you only want certain people to be able to edit the workbook you could try .

Code:
Private Sub Workbook_Open()
a = Environ("username")
If a = "Permitted user" Then
Exit Sub
end if

'Protect Worksheet Here

End Sub

DP
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi Richard

You could include within the macro code an unprotection ... and reprotection routine (and run macro code between the two ie whn the sheet is unprotected):

Code:
Sub mySub()
Activesheet.Unprotect "Password"
'do stuff...
'....
Activesheet.Protect "Password"
End Sub

You will then need to consider protecting your VBA project eg if you don't want users to see the protection password.
 
Upvote 0

RichardU

Board Regular
Joined
Aug 3, 2007
Messages
98
Thanks thats a great help, and the password does not need to be hidden as it is just so that novice excel users dont ruin my formatting etc.

Also is it possible to allow certain locked cells to be tabed to even when they are locked?
i.e.

o = locked
o = unlocked
o = locked cells i want to tab to

o o o o o o

???
 
Upvote 0

Forum statistics

Threads
1,190,794
Messages
5,982,956
Members
439,808
Latest member
agutosay

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
Top