Check Box

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

Guest

Hi - this sort of works, however if the checkbox is ticked and I
then change the value in K33, l6 doesnt change in tandem,
I have to untick and then tick again - think an extra line is needed
Thanks A Lot for any help

Sub checkbox1_click()

If CheckBox1.Value Then
Range("l6") = Range("k33")
Else
Range("l6") = 0
End If
End Sub
 
Hi

the code will only run if you tick the checkbox - as that's the event you've
coded against. if you want the code to run when k33 is changed AND the text
box is checked you'll need to code against a worksheet_change event.

e.g.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo err_handler
If CheckBox1.Value = True And Target.Address = "$K$33" Then
Range("I16").Value = Target.Value
Else
Range("i16").Value = 0
End If
err_handler:
Application.EnableEvents = True
End Sub

--
to use this code, right mouse click on the sheet tab with your checkbox and
choose view code - copy & paste the code directly in to the right hand side
of the screen

hope this helps
Cheers
JulieD
 
Perhaps you want to do this:
Sub checkbox1_click()

If CheckBox1.Value Then
Range("l6").Formula = "=K33"
Else
Range("l6").Value = 0
End If
End Sub
 
Sub checkbox1_click()

If CheckBox1.Value Then
Range("L6").formula = "=K33"
Else
Range("L6") = 0
End If
End Sub
 
Teresa,

I responded in the original thread.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Back
Top