Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how to determine which checkboxes are checked

Hi,
I have 40 check boxes in an application. I want to determine
programatically, which checkboxes the user has ticked (or checked).
based on the checkbox ticked i want to run some code. is there some way
in excel to comprehensively determine this? currently i am using if-then
condition 40 times! the names of my checkboxes are very intuitive :
checkbox1, checkbox2, checkbox3...

thanks in advance,
tina

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default how to determine which checkboxes are checked

Are these on a worksheet?

If you used a linked cell (in a nice range), you could do:

=countif(a1:a40,TRUE)


tina salgia wrote:

Hi,
I have 40 check boxes in an application. I want to determine
programatically, which checkboxes the user has ticked (or checked).
based on the checkbox ticked i want to run some code. is there some way
in excel to comprehensively determine this? currently i am using if-then
condition 40 times! the names of my checkboxes are very intuitive :
checkbox1, checkbox2, checkbox3...

thanks in advance,
tina

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how to determine which checkboxes are checked



Hi Dave,
The buttons reside on a worksheet. I havent linked these buttons to any
cell. they are standalone (i dont know if this is the correct term).
so i cannot use the method that you described. but if you can tell me
how to link them to cells, then it would probably make my life easier.
also if you cud suggest something with my current setting, it would be
great!
Thanks
Tina

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default how to determine which checkboxes are checked

What kind of checkboxes are they? Did you get them from the Forms toolbar or
from the ControlToolbox toolbar?

The first uses the Forms toolbar. The second from the ControlToolbox toolbar.


Option Explicit
Sub testme01()

Dim myCBX As CheckBox
Dim iCtr As Long

iCtr = 0
For Each myCBX In ActiveSheet.CheckBoxes
If myCBX.Value = xlOn Then
iCtr = iCtr + 1
End If
Next myCBX

MsgBox iCtr

End Sub

Sub testme02()

Dim OLEObj As OLEObject
Dim iCtr As Long

iCtr = 0
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
If OLEObj.Object.Value = True Then
iCtr = iCtr + 1
End If
End If
Next OLEObj

MsgBox iCtr

End Sub

You can just rightclick on the forms toolbar checkboxes, choose format control,
then Control Tab to get to the cell link.

For the controltoolbox checkboxes. Show that toolbar. Click on design mode.
Right click on the checkbox and select properties. Look for linkedcell.

If I was only looking to add them up, I wouldn't bother linking them. But if I
wanted to examine each (one by one), I might.




tina salgia wrote:

Hi Dave,
The buttons reside on a worksheet. I havent linked these buttons to any
cell. they are standalone (i dont know if this is the correct term).
so i cannot use the method that you described. but if you can tell me
how to link them to cells, then it would probably make my life easier.
also if you cud suggest something with my current setting, it would be
great!
Thanks
Tina

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how to determine which checkboxes are checked



thanks a lot! that really helped!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default how to determine which checkboxes are checked

Hi Tina Salgia,

Which textbox tool are you using? From Form toolbar or from Control Toolbox
bar?

Regards,

---
Orlando Magalhães Filho

(So that you get best and rapid solution and all may benefit from the
discussion, please reply within the newsgroup, not in email)

"tina salgia" escreveu na mensagem
...
Hi,
I have 40 check boxes in an application. I want to determine
programatically, which checkboxes the user has ticked (or checked).
based on the checkbox ticked i want to run some code. is there some way
in excel to comprehensively determine this? currently i am using if-then
condition 40 times! the names of my checkboxes are very intuitive :
checkbox1, checkbox2, checkbox3...

thanks in advance,
tina

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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 can I count checkboxes that have been checked? Jay Excel Discussion (Misc queries) 3 May 4th 09 05:16 PM
Checkbox checked then show more checkboxes Sara New Users to Excel 3 September 10th 08 07:16 PM
Print a selection based on checked checkboxes Stefan van der Hooft Excel Worksheet Functions 0 May 2nd 07 09:34 AM
Sum Only Checked Checkboxes Beamers Excel Discussion (Misc queries) 3 October 23rd 06 10:52 PM
My checkboxes will not stay checked. NUMBnut Excel Discussion (Misc queries) 0 January 9th 06 09:01 PM


All times are GMT +1. The time now is 04:17 PM.

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

About Us

"It's about Microsoft Excel"