There are two checkbox's that can be placed on a worksheet without using a UserForm. The Control Menu CheckBox and the Forms Menu CheckBox, each codes differently!
Which do you use?
Once again how is the code to know which Sheet and which cell gets the value from the cell with the CheckBox Checked?
The sample below shows the use of both CheckBox types: [The sample adds a strike-through line to the text in the selected cell if the CheckBox is Checked or clears the strike-through.]
The "cbCheck" Sub must be run to work. The other is a Click Event and works automatically!
Sub cbCheck()
'Sheet module code!
'For a "Form CheckBox" used on a sheet.
'This is the assigned macro for that checkbox!
'myClick is the checkbox state indicator!
Static myClick
If myClick = "" Then
'ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
Selection.Font.Strikethrough = True
myClick = "Yes"
Else
ActiveCell.Select
Selection.Font.Strikethrough = False
myClick = ""
End If
End Sub
Private Sub CheckBox1_Click()
'Sheet module code!
'For a "Control Tool Box CheckBox" used on a sheet.
'Automatically runs code on CheckBox change.
If CheckBox1.Value = -1 Then
'ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
Selection.Font.Strikethrough = True
Else
Selection.Font.Strikethrough = False
End If
End Sub