kiyiya
07-19-2008, 05:44 AM
Hello all.
I have a "gazillion" checkboxes on a sheet that are used to put prices on the sheet. These are then looped through to find what to copy to another sheet. My problem (one of many at the moment) is that when I protect the worksheet, I get an error that the cell I am trying to change is protected..... Ok, protection works!
I have formuals that use the INDEX MATCH function to lookup the prices to put in the cells and so I thought the best way to handle it is unprotect the sheet and use my checkbox to do its thing and then protect the sheet again............. for some reason my code is not working.
Sub CB_1_Click()
application.ScreenUpdating = False
activesheet.unprotect
Sheet1.Range("H11").ClearContents
If Sheet1.Range("C11") = True Then
Sheet1.Range("H11") = "1"
Sheet1.Range("H11").Select
Else
If Sheet1.Range("c11") = False Then Sheet1.Range("H11") = ""
Sheet1.Range("F11").Select
End If
activesheet.protect
application.ScreenUpdating = True
End Sub
If I unprotect the sheet and then click the checkbox it works. However, with the sheet protected it doesn't work even though I tell it it to unprotect before going any further. It does protect the sheet when the code completes but it fails to unprotect the sheet again if I click the checkbox.
Suggestions?
I have a "gazillion" checkboxes on a sheet that are used to put prices on the sheet. These are then looped through to find what to copy to another sheet. My problem (one of many at the moment) is that when I protect the worksheet, I get an error that the cell I am trying to change is protected..... Ok, protection works!
I have formuals that use the INDEX MATCH function to lookup the prices to put in the cells and so I thought the best way to handle it is unprotect the sheet and use my checkbox to do its thing and then protect the sheet again............. for some reason my code is not working.
Sub CB_1_Click()
application.ScreenUpdating = False
activesheet.unprotect
Sheet1.Range("H11").ClearContents
If Sheet1.Range("C11") = True Then
Sheet1.Range("H11") = "1"
Sheet1.Range("H11").Select
Else
If Sheet1.Range("c11") = False Then Sheet1.Range("H11") = ""
Sheet1.Range("F11").Select
End If
activesheet.protect
application.ScreenUpdating = True
End Sub
If I unprotect the sheet and then click the checkbox it works. However, with the sheet protected it doesn't work even though I tell it it to unprotect before going any further. It does protect the sheet when the code completes but it fails to unprotect the sheet again if I click the checkbox.
Suggestions?