Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA array of checkboxes
I have 44 checkboxes on a VBA Excel form that I dragged
there from the Toolbox. I named them all rep1_cb, rep2_cb, rep3_cb, ... rep44_cb. I want to add a button to the forum to un/check all checkboxes within this "group". Is there some way to store them all within an array - or create some sort of loop without having to individually change the value of each and every one of them? Thanks! Eliezer |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA array of checkboxes
Eliezer
Here's a simple for each loop that looks at the names of all controls and reverses the values for the ones you designated as "rep" control check boxes: Private Sub cmdCheckBoxes_Click() Dim ctrl As Control For Each ctrl In Me.Controls If Left(ctrl.Name, 3) = "rep" Then ctrl.Value = Not ctrl.Value End If Next End Sub -- Charles www.officezealot.com "Eliezer" wrote in message ... I have 44 checkboxes on a VBA Excel form that I dragged there from the Toolbox. I named them all rep1_cb, rep2_cb, rep3_cb, ... rep44_cb. I want to add a button to the forum to un/check all checkboxes within this "group". Is there some way to store them all within an array - or create some sort of loop without having to individually change the value of each and every one of them? Thanks! Eliezer |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA array of checkboxes
Charles,
Excellent! Thanks! Eliezer -----Original Message----- Eliezer Here's a simple for each loop that looks at the names of all controls and reverses the values for the ones you designated as "rep" control check boxes: Private Sub cmdCheckBoxes_Click() Dim ctrl As Control For Each ctrl In Me.Controls If Left(ctrl.Name, 3) = "rep" Then ctrl.Value = Not ctrl.Value End If Next End Sub -- Charles www.officezealot.com "Eliezer" wrote in message ... I have 44 checkboxes on a VBA Excel form that I dragged there from the Toolbox. I named them all rep1_cb, rep2_cb, rep3_cb, ... rep44_cb. I want to add a button to the forum to un/check all checkboxes within this "group". Is there some way to store them all within an array - or create some sort of loop without having to individually change the value of each and every one of them? Thanks! Eliezer . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set up checkboxes in excel? | Excel Discussion (Misc queries) | |||
Excel Checkboxes | Excel Discussion (Misc queries) | |||
Checkboxes in Excel - Please Help! | Excel Discussion (Misc queries) | |||
setting ctl to array of checkboxes yields type mismatch error. | Excel Programming | |||
setting ctl to array of checkboxes yields type mismatch error. | Excel Programming |