M
Michelle
Hello, I have a userform with checkboxes for each of four years (Y0, Y1, Y2
& Y3)
I want to be able to tick them all by ticking the 'tick-all' checkbox
Similarly, if I deselect any of them the 'tick-all' box should be
automatically unchecked
and if I tick them all manually, the 'tick-all' box should be automatically
checked
I have seen this setup before - so I know it's possible.
My problem is that the event procedures are all triggering each other and so
it's a bit of a mess.
I've tried EnableEvents = false, but it doesn't do what I want
A sample of my code is below, but does anyone know a way to make it work?
please?
'===========================
Private Sub chkHeadAll_Change()
Application.EnableEvents = False
chkHeadY0.Value = chkHeadAll.Value
chkHeadY1.Value = chkHeadAll.Value
chkHeadY2.Value = chkHeadAll.Value
chkHeadY3.Value = chkHeadAll.Value
Application.EnableEvents = True
End Sub
Private Sub chkHeadY0_Change()
Application.EnableEvents = False
If chkHeadY0.Value And chkHeadY1.Value And chkHeadY2.Value And
chkHeadY3.Value Then chkHeadAll.Value = True
If Not chkHeadY0.Value Or Not chkHeadY1.Value Or Not chkHeadY2.Value Or
Not chkHeadY3.Value Then chkHeadAll.Value = False
Application.EnableEvents = True
End Sub
Private Sub chkHeadY1_Change()
Application.EnableEvents = False
If chkHeadY0.Value And chkHeadY1.Value And chkHeadY2.Value And
chkHeadY3.Value Then chkHeadAll.Value = True
If Not chkHeadY0.Value Or Not chkHeadY1.Value Or Not chkHeadY2.Value Or
Not chkHeadY3.Value Then chkHeadAll.Value = False
Application.EnableEvents = True
End Sub
'===========================
Thanks
M
& Y3)
I want to be able to tick them all by ticking the 'tick-all' checkbox
Similarly, if I deselect any of them the 'tick-all' box should be
automatically unchecked
and if I tick them all manually, the 'tick-all' box should be automatically
checked
I have seen this setup before - so I know it's possible.
My problem is that the event procedures are all triggering each other and so
it's a bit of a mess.
I've tried EnableEvents = false, but it doesn't do what I want
A sample of my code is below, but does anyone know a way to make it work?
please?
'===========================
Private Sub chkHeadAll_Change()
Application.EnableEvents = False
chkHeadY0.Value = chkHeadAll.Value
chkHeadY1.Value = chkHeadAll.Value
chkHeadY2.Value = chkHeadAll.Value
chkHeadY3.Value = chkHeadAll.Value
Application.EnableEvents = True
End Sub
Private Sub chkHeadY0_Change()
Application.EnableEvents = False
If chkHeadY0.Value And chkHeadY1.Value And chkHeadY2.Value And
chkHeadY3.Value Then chkHeadAll.Value = True
If Not chkHeadY0.Value Or Not chkHeadY1.Value Or Not chkHeadY2.Value Or
Not chkHeadY3.Value Then chkHeadAll.Value = False
Application.EnableEvents = True
End Sub
Private Sub chkHeadY1_Change()
Application.EnableEvents = False
If chkHeadY0.Value And chkHeadY1.Value And chkHeadY2.Value And
chkHeadY3.Value Then chkHeadAll.Value = True
If Not chkHeadY0.Value Or Not chkHeadY1.Value Or Not chkHeadY2.Value Or
Not chkHeadY3.Value Then chkHeadAll.Value = False
Application.EnableEvents = True
End Sub
'===========================
Thanks
M