Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Locking cells with a checkbox using a macro.
Hello. I have an ongoing problem. I am trying to lock cells so they
cannot be changed as long as a checkbox on the active sheet is checked. I have some code, but it runs an error and doesn't quite work anyway. I have another macro that fills the boxes with values, but I want the users to be able to adjust those values. Only after the checkbox is checked, I want the access to those cells to be locked. Here is a sampling of the code I have so far: Sub chkLockAttribs_Click() ' 'Private Sub chkLockAttribs_Click() Dim myRng As Range Dim myPwd As String myPwd = "secret" Set myRng = ActiveSheet.Range("C18, D19:D23, D25, D26:F26, J19:J23, P33, P35") ActiveSheet.Unprotect Password:=myPwd myRng.Locked = ActiveSheet.OLEObjects("chkLockAttribs").Object.Va lue ActiveSheet.cmdRoll.Visible = Not (ActiveSheet.chkLockAttribs.Value) ActiveSheet.Protect Password:=myPwd End Sub The checkbox is chkLockAttribs and the button linked to a macro generating values is cmdRoll. C18, D19:D23, D25, D26:F26, J19:J23, P33, P35 is the range of cells I want to lock after the checkbox is checked. I don't really need a password protection on this. It's more a convienence thing. So any suggestions? Any and all help appreciated. -SplatterKat- aka -Robert Lizak- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Locking everything except cells B4:B8 | New Users to Excel | |||
Locking cells | Excel Worksheet Functions | |||
Locking Cells | Excel Discussion (Misc queries) | |||
locking formula in cells in without locking whole sheet | Excel Discussion (Misc queries) | |||
Locking cells | Excel Programming |