If you use the checkbox from the control toolbox, then click on the design mode
icon (also on that toolbar) and double click on that checkbox.
You'll be taken to where you should place the code.
This worked for me:
Option Explicit
Private Sub CheckBox1_Click()
Dim myCell As Range
Set myCell = Me.Range("a1")
Me.Unprotect Password:="hi"
If Me.CheckBox1.Value = True Then
myCell.Value = "It's on"
Else
myCell.Value = "it's off"
End If
Me.Protect Password:="hi"
End Sub
It's almost the same--notice that activesheet. was replaced with Me. Me is the
object that owns the code--in this case it's the worksheet that holds that
checkbox from the control toolbox toolbar.
One nice thing about using the checkbox from the forms toolbar is you can assign
the same macro to each checkbox. (You'd have to add a bit to make sure you got
the correct corresponding cell, though.)
But with the checkboxes from the control toolbox toolbar, each checkbox has its
own code.
Dave,
What about making this work using a Check Box from the "Control Toolbox"
rather than the forms toolbox. Is that possible?