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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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
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
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,214,411
Messages
6,119,360
Members
448,888
Latest member
Arle8907

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