Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Iterate through a form


Hi. This is probably easy stuff, but I can't seem to do it!

Here goes...

I have a form that contains several OptionButtons. These are all hel
in a frame on my UserForm. There are also Labels in the frame next t
the OptionButton that identifies its purpose to the user.

I would like to find a way of iterating through the frame to identif
which OptionButton has been selected. Then, using the associate
Caption of the OptionButton I would like to enter this value into
cell on a worksheet.

I've been having real trouble with this. I'm just trying to do
project for work that will really make my life easier there, I'm not a
Excel superuser!

If anyone can help I'd be real grateful.

Thanks,

Rob

--
RobEdgele
-----------------------------------------------------------------------
RobEdgeler's Profile: http://www.excelforum.com/member.php...fo&userid=2733
View this thread: http://www.excelforum.com/showthread.php?threadid=46835

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Iterate through a form

Is there a reason you didn't use the caption of the optionbutton as the
identifier?

If I named the optionbuttons and labels nicely, this worked ok:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim myCtrl As Control
Dim iCtr As Long
Dim FoundIt As Boolean
iCtr = 0
FoundIt = False
For Each myCtrl In Me.Frame1.Controls
If TypeOf myCtrl Is MSForms.OptionButton Then
iCtr = iCtr + 1
If myCtrl.Value = True Then
MsgBox myCtrl.Caption
FoundIt = True
Exit For
End If
End If
Next myCtrl

If FoundIt = True Then
MsgBox Me.Frame1.Controls("Label" & iCtr).Caption
Else
MsgBox "Nothing selected"
End If
End Sub

That "msgbox myctrl.caption" might be all you really need with a minor change to
the form???

RobEdgeler wrote:

Hi. This is probably easy stuff, but I can't seem to do it!

Here goes...

I have a form that contains several OptionButtons. These are all held
in a frame on my UserForm. There are also Labels in the frame next to
the OptionButton that identifies its purpose to the user.

I would like to find a way of iterating through the frame to identify
which OptionButton has been selected. Then, using the associated
Caption of the OptionButton I would like to enter this value into a
cell on a worksheet.

I've been having real trouble with this. I'm just trying to do a
project for work that will really make my life easier there, I'm not an
Excel superuser!

If anyone can help I'd be real grateful.

Thanks,

Rob.

--
RobEdgeler
------------------------------------------------------------------------
RobEdgeler's Profile: http://www.excelforum.com/member.php...o&userid=27336
View this thread: http://www.excelforum.com/showthread...hreadid=468356


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Iterate through a form


Thank you very much for your help, I'm pleased to say that it work
really good!

Have a nice day.

Rob.
:) :) :) :

--
RobEdgele
-----------------------------------------------------------------------
RobEdgeler's Profile: http://www.excelforum.com/member.php...fo&userid=2733
View this thread: http://www.excelforum.com/showthread.php?threadid=46835

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
Iterate Circular Reference Brandt Excel Discussion (Misc queries) 1 August 3rd 05 11:43 PM
Iterate through controls lgbjr Excel Programming 3 May 28th 05 02:09 PM
How to iterate through all Text Boxes on a Form? Ed Excel Programming 5 February 16th 05 01:24 PM
Can't iterate thru a row with For peter Excel Programming 2 January 7th 05 04:46 AM
Iterate columns wired Excel Programming 9 November 14th 03 11:14 PM


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