sconly
04-12-2010, 07:28 AM
I have a worksheet with numerous (control toolbox) checkboxes on it.
What I am trying to achieve is by clicking one checkbox (lets call it the master) i want to enable/disable the other checkboxes (whos name starts with 'chkDam').
My code (see below) doesn't seem to want to work.......Any advice?
Dim ctlC As Control
For Each ctlC In Controls
If chkNoInjury.Value = True Then
MsgBox ctlC.Name
If TypeOf ctlC Is CheckBox Then
If Left(ctlC.Name, 6) = "chkDam" Then
ctlC.Enabled = False
End If
End If
Else
If TypeOf ctlC Is CheckBox Then
If ctlC.Name Like "chkDam*" Then
ctlC.Enabled = True
End If
End If
End If
Next ctlC
Thanks
PS. I get the following error 'Run-time error 424 Object required'
What I am trying to achieve is by clicking one checkbox (lets call it the master) i want to enable/disable the other checkboxes (whos name starts with 'chkDam').
My code (see below) doesn't seem to want to work.......Any advice?
Dim ctlC As Control
For Each ctlC In Controls
If chkNoInjury.Value = True Then
MsgBox ctlC.Name
If TypeOf ctlC Is CheckBox Then
If Left(ctlC.Name, 6) = "chkDam" Then
ctlC.Enabled = False
End If
End If
Else
If TypeOf ctlC Is CheckBox Then
If ctlC.Name Like "chkDam*" Then
ctlC.Enabled = True
End If
End If
End If
Next ctlC
Thanks
PS. I get the following error 'Run-time error 424 Object required'