Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Option buttons: How to get the selected option from a group?


Hi,

I have a form in which I have yes/no questions. The user has to answer
the questions and at the end i need to display the score.
So I have several groups of 2 option buttons (Yes/No) and I would like
to know how I can find out which option is selected from a group.
Say group1 has "Yes" selected, I would like to have something like the
following:


Code:
--------------------
if group1.selected.label = "Yes" then countYes++ end if
--------------------


Can anyone help me?

Also, while I'm at it, I have about 25 questions so I have 25 groups.
Is there a smarter way to calculate the total score than type in the
line above for each and every group manually?

Thanks all,


--
naddad
------------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...o&userid=29817
View this thread: http://www.excelforum.com/showthread...hreadid=495201

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Option buttons: How to get the selected option from a group?

maybe something like this
dim c as control
for each c in controls
if typename(c)="Option Button" then
if c.value="Yes" then
countyes++
endif
endif
next

(I'm not 100% sure of the typename, but something like this should work)

J

"naddad" wrote:


Hi,

I have a form in which I have yes/no questions. The user has to answer
the questions and at the end i need to display the score.
So I have several groups of 2 option buttons (Yes/No) and I would like
to know how I can find out which option is selected from a group.
Say group1 has "Yes" selected, I would like to have something like the
following:


Code:
--------------------
if group1.selected.label = "Yes" then countYes++ end if
--------------------


Can anyone help me?

Also, while I'm at it, I have about 25 questions so I have 25 groups.
Is there a smarter way to calculate the total score than type in the
line above for each and every group manually?

Thanks all,


--
naddad
------------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...o&userid=29817
View this thread: http://www.excelforum.com/showthread...hreadid=495201


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Option buttons: How to get the selected option from a group?

i think countYes++ might need to be
countYes = countYes + 1

J

"Gixxer_J_97" wrote:

maybe something like this
dim c as control
for each c in controls
if typename(c)="Option Button" then
if c.value="Yes" then
countyes++
endif
endif
next

(I'm not 100% sure of the typename, but something like this should work)

J

"naddad" wrote:


Hi,

I have a form in which I have yes/no questions. The user has to answer
the questions and at the end i need to display the score.
So I have several groups of 2 option buttons (Yes/No) and I would like
to know how I can find out which option is selected from a group.
Say group1 has "Yes" selected, I would like to have something like the
following:


Code:
--------------------
if group1.selected.label = "Yes" then countYes++ end if
--------------------


Can anyone help me?

Also, while I'm at it, I have about 25 questions so I have 25 groups.
Is there a smarter way to calculate the total score than type in the
line above for each and every group manually?

Thanks all,


--
naddad
------------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...o&userid=29817
View this thread: http://www.excelforum.com/showthread...hreadid=495201


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Option buttons: How to get the selected option from a group?


thanks, TypeName(c) returns "OptionButton"
But c is a control, is there a way to cast it to an OptionButton so i
recognizes the caption

--
nadda
-----------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...fo&userid=2981
View this thread: http://www.excelforum.com/showthread.php?threadid=49520

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Option buttons: How to get the selected option from a group?

Dim c As Control
For Each c In Controls
If TypeName(c) = "OptionButton" Then
If c.Value = True Then
countYes = countYes + 1
End If
End If
Next

this worked for me

J
"naddad" wrote:


thanks, TypeName(c) returns "OptionButton"
But c is a control, is there a way to cast it to an OptionButton so it
recognizes the caption?


--
naddad
------------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...o&userid=29817
View this thread: http://www.excelforum.com/showthread...hreadid=495201




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Option buttons: How to get the selected option from a group?

I'm sorry - i think i misunderstood your need.
you're wanting to count how many option buttons that have "Yes" as the text
are selected.

Dim c As Control
For Each c In Controls
If TypeName(c) = "OptionButton" Then
If c.Value = True And c.Caption = "Yes" Then
countYes = countYes + 1
End If
End If
Next

"naddad" wrote:


thanks, TypeName(c) returns "OptionButton"
But c is a control, is there a way to cast it to an OptionButton so it
recognizes the caption?


--
naddad
------------------------------------------------------------------------
naddad's Profile: http://www.excelforum.com/member.php...o&userid=29817
View this thread: http://www.excelforum.com/showthread...hreadid=495201


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
option buttons / group box texas2001 Excel Discussion (Misc queries) 1 December 17th 09 06:43 PM
Grouping Option Buttons ion a Group Box [email protected] New Users to Excel 5 October 15th 06 07:29 PM
group option buttons umba-sr Excel Discussion (Misc queries) 1 March 7th 06 02:03 PM
Option Buttons in Group Box JAMES T. Excel Discussion (Misc queries) 4 March 22nd 05 08:59 PM
Group Box with Option Buttons Tom Ogilvy Excel Programming 0 April 1st 04 04:15 AM


All times are GMT +1. The time now is 01:52 AM.

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"