Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking cells with VBA

Status
Not open for further replies.

Jazztpt

Vendor
Feb 16, 2005
50
Hi - (Excel 2000) I am trying to lock a range of cells when a checkbox is 'ticked' - I thought this would work, but it doesn't !

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Range("A1:E4").Locked = True
Else
Range("A1:E4").Locked = False
End If
End Sub

Can anyone tell me what i am doing wrong.
Thanks
Jazztpt
 
Locking the cells will only work if you've protected the sheet. You need to unprotect it, change the lock status and then protect it again.

Question is then whether you want to hardcode a password in the sheet protection (and then protect the VBA project so others can't find it from the VB code).
 
Thanks for the reply, I'll give that a go.
Cheers
Jazztpt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top