Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Accessing groups of option buttons

Hi folks,

Thanks for taking time to read this and for any advice you offer!

I have a userform with 27 rows of controls.

Each row contains a label control, the value of which is assigned
during the userforms initiate sub.

Next to each label there are 6 option buttons. I have grouped each
label and its option buttons with a frame.

At the moment I am cycling through all of the controls to find which
option button has been selected from each group, as follows:

Private Sub btnRunTrawl_Click()
Dim Ctr As Control

For Each Ctr In
UFSetUpDataTrawl.Controls
If TypeName(Ctr) =
"OptionButton" Then .......


Is there an easier way, for instance can I access each group of
controls separately?


Thanks again for any help you can offer.

Brotherwarren




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Accessing groups of option buttons

i do something very similar. but when i enter a frame, i reset the values of the
optionbuttons in the other frames to false with something like this:

Private Sub Frame1_Enter()
For Each cntrl In UserForm13.Frame2.Controls
If cntrl.Value = True Then
cntrl.Value = False
End If
Next
end sub
--


Gary


"Brotherwarren" wrote in message
...
Hi folks,

Thanks for taking time to read this and for any advice you offer!

I have a userform with 27 rows of controls.

Each row contains a label control, the value of which is assigned
during the userforms initiate sub.

Next to each label there are 6 option buttons. I have grouped each
label and its option buttons with a frame.

At the moment I am cycling through all of the controls to find which
option button has been selected from each group, as follows:

Private Sub btnRunTrawl_Click()
Dim Ctr As Control

For Each Ctr In
UFSetUpDataTrawl.Controls
If TypeName(Ctr) =
"OptionButton" Then .......


Is there an easier way, for instance can I access each group of
controls separately?


Thanks again for any help you can offer.

Brotherwarren






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Accessing groups of option buttons

The userform has controls which includes buttons and frames. The frames have
controls which only include the buttons in the frame. So first find each of
the frames and ten look for the controls in each of the frames like the code
below.


Sub test()

For Each cntl In UserForm1.Controls
If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls
MsgBox (itm.Name)
Next itm

End If

Next cntl

End Sub


"Brotherwarren" wrote:

Hi folks,

Thanks for taking time to read this and for any advice you offer!

I have a userform with 27 rows of controls.

Each row contains a label control, the value of which is assigned
during the userforms initiate sub.

Next to each label there are 6 option buttons. I have grouped each
label and its option buttons with a frame.

At the moment I am cycling through all of the controls to find which
option button has been selected from each group, as follows:

Private Sub btnRunTrawl_Click()
Dim Ctr As Control

For Each Ctr In
UFSetUpDataTrawl.Controls
If TypeName(Ctr) =
"OptionButton" Then .......


Is there an easier way, for instance can I access each group of
controls separately?


Thanks again for any help you can offer.

Brotherwarren





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Accessing groups of option buttons

Excellent work!

Thanks Joel.


One more thing, is there a benefit to using:

If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls

instead of:

if typename(cntl) = "Frame" then

?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Accessing groups of option buttons

Excellent work!

Thanks Joel.


One more thing, is there a benefit to using:

If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls

instead of:

if typename(cntl) = "Frame" then

?

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
Groups in Option buttons Greg B[_12_] Excel Programming 15 January 24th 08 07:09 PM
with multiple option buttons on my form how do I isolate groups sabrina Excel Worksheet Functions 4 September 17th 07 10:06 PM
Two Groups of Option Buttons on Worksheet Jim May Excel Discussion (Misc queries) 0 June 24th 06 09:34 PM
Navigating between option buttons is not selecting the option Gixxer_J_97[_2_] Excel Programming 4 June 2nd 05 02:50 PM
Option Buttons - groups Ciara Excel Discussion (Misc queries) 4 May 18th 05 05:41 PM


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