Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up checkboxes in excel? Mwango Excel Discussion (Misc queries) 1 September 8th 06 11:15 AM
Excel Checkboxes nir020 Excel Discussion (Misc queries) 1 August 29th 06 11:28 AM
Checkboxes in Excel - Please Help! TotallyConfused Excel Discussion (Misc queries) 3 October 27th 05 08:47 PM
setting ctl to array of checkboxes yields type mismatch error. tritan Excel Programming 0 July 11th 03 09:22 PM
setting ctl to array of checkboxes yields type mismatch error. Tritan Excel Programming 0 July 11th 03 07:50 PM


All times are GMT +1. The time now is 07:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"