Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Koila Malik   on Jan 04 In MS Office Category.

  
Question Answered By: Phoebe Brown   on Jan 04

A few things to help troubleshoot this thing would be to view the
Locals Window so you can see the values of all your variables, then
place a break point right at the begining of your CheckBox1_Click
subroutine. Then, click the check  box and step through it by
pressing F8.

You will see that the value of LinkedCell is not being passed to
your subroutine. See the code below for a solution to this and some
other minor things.

Private Sub CheckBox1_Click()
Dim LinkedCell As Boolean

'LinkedCell is a named  range for A3 - A3 is where the
'checkbox result  is stored

'*You need to transfer the value from
'*the named range  into a variable.
'*The same name can be used.
LinkedCell = Range("LinkedCell")

'*If LinkedCell = 1 Then
'*Since LinkedCell is a boolean,
'*change to the following
If LinkedCell Then
Call Protect
Else
Call Unprotect
End If

End Sub
Sub Protect()
'*make sure LinkedCell is not locked
'*or we won't be able to change back
'*to unprotected
Range("LinkedCell").Locked = False
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub

Sub Unprotect()
ActiveSheet.Unprotect
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Protect, unprotect sheet from checkbox control Or get search suggestion and latest updates.


Tagged: