PC Review


Reply
Thread Tools Rate Thread

Counting OptionButtons

 
 
Patrick C. Simonds
Guest
Posts: n/a
 
      15th Aug 2009
I have 11 identical groups of OptionButtons each group consists of 6
OpTionButtons. Each group has its own groupname. Is there any way to count
how many of OptionButton4's have a True value?

 
Reply With Quote
 
 
 
 
Matthew Herbert
Guest
Posts: n/a
 
      15th Aug 2009
On Aug 14, 5:55*pm, "Patrick C. Simonds" <ordnan...@comcast.net>
wrote:
> I have 11 identical groups of OptionButtons each group consists of 6
> OpTionButtons. Each group has its own groupname. Is there any way to count
> how many of OptionButton4's have a True value?


Patrick,

Some sample code is below. I haven't tested it, but it should work.
I'm assuming your user form is UserForm1 and the target frame is
Frame1. Of course, you can adjust the user form and frame as needed.

Best,

Matthew Herbert

Dim Ctrl As MSForms.Control
Dim intCnt As Integer

For Each Ctrl In UserForm1.Frame1.Controls
If TypeOf Ctrl Is MSForms.OptionButton Then
If Ctrl.Value = True Then
intCnt = intCnt + 1
End If
End If
Next Ctrl

MsgBox "The number of true values in the specified " & vbLf & _
"form and frame is " & intCnt & "."
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      15th Aug 2009
You are going to have to clarify what you mean by "count how many of
OptionButton4's have a True Value"... only one control on a UserForm can
have the name OptionButton4; and, if you mean OptionButton4 is the GroupName
you want to check, then only one control within that GroupName collection
can be True at any given time.

--
Rick (MVP - Excel)


"Patrick C. Simonds" <(E-Mail Removed)> wrote in message
news:C08CFF0A-8F1E-4CAC-8E73-(E-Mail Removed)...
>I have 11 identical groups of OptionButtons each group consists of 6
>OpTionButtons. Each group has its own groupname. Is there any way to count
>how many of OptionButton4's have a True value?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
OptionButtons St@cy Microsoft Powerpoint 1 3rd Jan 2009 06:21 PM
optionbuttons Ineke Microsoft Outlook Form Programming 1 30th Mar 2004 02:14 PM
OptionButtons T-man Microsoft Outlook Form Programming 8 3rd Feb 2004 01:44 PM
Using optionbuttons =?Utf-8?B?QVNHOTA=?= Microsoft Excel Setup 1 16th Jan 2004 03:34 AM
optionbuttons Phil Perry Microsoft Excel Programming 1 10th Jul 2003 09:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:14 PM.