#1   Report Post  
Posted to microsoft.public.excel.programming
OMG OMG is offline
external usenet poster
 
Posts: 1
Default Check Boxes

I've placed several check boxes in a worksheet (not on a form). What I want to do through VBA is to iterate through all the check boxes and, where the "Value" property returns True then read the caption. My problem is that I can't figure out how to iterate through the boxes efficiently. With the worksheet name of "Parameters" I've tried "Parameters.CheckBox1.Value" but I want to be able to just get a collection of all checkboxes on the page and iterate

Any ideas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Check Boxes

If these are checkboxes from the Forms toolbar, use code like the
following:

Dim CHK As Excel.CheckBox
For Each CHK In ActiveSheet.CheckBoxes
If CHK.Value = 1 Then
MsgBox CHK.Caption
End If
Next CHK

If these are checkboxes from the Controls toolbar, use code like
the following:

Dim Obj As OLEObject
For Each Obj In ActiveSheet.OLEObjects
If TypeOf Obj.Object Is MSForms.CheckBox Then
If Obj.Object.Value Then
MsgBox Obj.Object.Caption
End If
End If
Next Obj


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"OMG" wrote in message
...
I've placed several check boxes in a worksheet (not on a form).

What I want to do through VBA is to iterate through all the check
boxes and, where the "Value" property returns True then read the
caption. My problem is that I can't figure out how to iterate
through the boxes efficiently. With the worksheet name of
"Parameters" I've tried "Parameters.CheckBox1.Value" but I want
to be able to just get a collection of all checkboxes on the page
and iterate.

Any ideas



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check Boxes

Perfect. Thanks for your help.
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
Copy and move check box (check boxes) with new cell link? Marty Excel Worksheet Functions 1 January 20th 10 07:43 PM
How do I increase the size of check in check boxes Adams, Les Excel Discussion (Misc queries) 0 September 19th 06 02:35 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
How do i create a value for check boxes or option boxes Tim wr Excel Discussion (Misc queries) 1 February 9th 06 10:29 PM
Check Box influencing other Check Boxes Dave Ramage[_2_] Excel Programming 0 September 4th 03 02:14 PM


All times are GMT +1. The time now is 07:09 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"