Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Counting OptionButtons

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Counting OptionButtons

On Aug 14, 5:55*pm, "Patrick C. Simonds"
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 & "."
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Counting OptionButtons

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" wrote in message
...
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
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
UserForm OptionButtons Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 3 October 4th 07 07:52 PM
c# & InterOp & OptionButtons Timo Excel Programming 0 February 13th 06 08:15 AM
OptionButtons Paul Excel Programming 4 December 4th 03 04:12 PM
Add OptionButtons in Excel Andrew Lenczycki Excel Programming 0 July 30th 03 02:34 PM
optionbuttons Phil Perry Excel Programming 1 July 10th 03 09:13 PM


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

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"