Check Box Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you make if True, Display the value of Sheet2 Cell B4? Below will not work

Private Sub CheckBox1_Click(
With CheckBox
If CheckBox1.Value = True Then ActiveSheet.Range("A2").Value = "Sheet2!$B$4
If CheckBox1.Value = False Then ActiveSheet.Range("A2") = "
End Wit
End Su

Thank you
 
Try putting true and false in quotes. Like "True"
and "False". Remember it's case sensitive.
 
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then ActiveSheet.Range("A2").Value =
"Sheet2!$B$4"
If CheckBox1.Value = False Then ActiveSheet.Range("A2") = ""
End Sub


or

Private Sub CheckBox1_Click()
With CheckBox1
If .Value = True Then ActiveSheet.Range("A2").Value = "Sheet2!$B$4"
If .Value = False Then ActiveSheet.Range("A2") = ""
End With
End Sub
 
Watch for word wrap:

Private Sub CheckBox1_Click()
With CheckBox1
If .Value = True Then ActiveSheet.Range("A2").Value =
Range("Sheet2!$B$4").Value
If .Value = False Then ActiveSheet.Range("A2").Value = ""
End With
End Sub

or possibly
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.Range("A2").Value = Range("Sheet1!$B$4").Value
Else
ActiveSheet.Range("A2") = ""
End If
End Sub
 
Back
Top