Simple Way To Step Through Checkboxes
Folks,
Im hoping this is a simple question and Im just being dense. I have a user form with around 30 check boxes, to select different graphs to be displayed or hidden. I am wanting to cycle through the checkboxes and then for each, if the user has checked the box display the relevant series on the graphs. So the question is how do I step from checkbox to checkbox to determine its value. Thanks for any help, Andrew |
Simple Way To Step Through Checkboxes
Hi,
Try this, Dim ctl As Object For Each ctl In userform1.Controls 'if within userform's codmodule 'For Each ctl In me.Controls If TypeName(ctl) = "CheckBox" Then If ctl.Value Then MsgBox ctl.Name & " : marked" End If Next Regards, Shah Shailesh http://members.lycos.co.uk/shahweb/ *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Simple Way To Step Through Checkboxes
hi,
Thats great. Thanks for the quick reply. Andrew *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Simple Way To Step Through Checkboxes
Hi,
Not tested but try this: Dim myControl As MSForms.Control For Each myControl In myForm.Controls If TypeOf myControl Is MSForms.CheckBox Then 'something to do with myControl.Value End If 'typeof Next myControl regards Paul (Andrew) wrote in message . com... Folks, Im hoping this is a simple question and Im just being dense. I have a user form with around 30 check boxes, to select different graphs to be displayed or hidden. I am wanting to cycle through the checkboxes and then for each, if the user has checked the box display the relevant series on the graphs. So the question is how do I step from checkbox to checkbox to determine its value. Thanks for any help, Andrew |
Simple Way To Step Through Checkboxes
Well, the Userform object has a Controls collection which you could
loop through and do a TypeOf comparison to test which are CheckBox. However, you would make things easier on yourself if in the form's _Activate event you put all the relevant checkboxes into your own Collection, array or similar, then you'd *know* where to look for them later. -- (Andrew) wrote in message . com... Folks, Im hoping this is a simple question and Im just being dense. I have a user form with around 30 check boxes, to select different graphs to be displayed or hidden. I am wanting to cycle through the checkboxes and then for each, if the user has checked the box display the relevant series on the graphs. So the question is how do I step from checkbox to checkbox to determine its value. Thanks for any help, Andrew |
All times are GMT +1. The time now is 05:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com