Check Box Format!

K

Kim-Anh Tran

I have a check box. I would like to have this happens:
1. When the box is checked, it will appear "Y" in cell B4.
2. When it is unchecked, it will appear "N" in cell B4.
How do I make this happens?

Thanks in advance for your help!
Kim-An
 
B

Bob Kilmer

Add this code (assumes name of checkbox is CheckBox1):

Private Sub CheckBox1_Click()
If CheckBox1.Value Then
Range("B4").Value = "Y"
Else
Range("B4").Value = "N"
End If
End Sub
 
K

Kim-Anh Tran

I forgot that cell "B4" is in another sheet!
How do I indicate the location of the cell B4?
Thanks again!
Kim-An
 
T

Tom Ogilvy

Private Sub CheckBox1_Click()
With Worksheets("Sheet5")
If CheckBox1.Value Then
.Range("B4").Value = "Y"
Else
.Range("B4").Value = "N"
End If
End With
End Sub
 
K

Kim-Anh Tran

Check box40 is in sheet 1 and Cell "B4" is in sheet 2.
I appreciate anyone help to fix this problem! I have the error message
"Can't execute code in break mode"

Private Sub CheckBox40_Click()
With Worksheets("sheet 2")
If CheckBox40.Value Then
Range("B4").Value = "Y"
Else
Range("B4").Value = "N"
End If
End With
End Su
 
B

Bob Kilmer

The message means code execution has been stopped (it is taking a "break".).
Either an error has paused execution for debug mode or you have paused
execution, yet the checkbox is trying to execute its code. Reset the code.
On the Run menu, click Reset <yourprojectname> and try again.
 
Top