Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Option Button and forms

I am having problems with MSForms.OptionButton Function.
I have 5 userforms, and in each form there are 5 option buttons of
which the user select one. The program will need to trace the option
chosen and input it into a worksheet.I have used the below stated code
but it doesn't work for userform 2, 3, 4, and 5. It seems to be able
to work for the first form-userForm1. Any help is appreciated.

Private Sub OptionButton1 Click()
setoption
End Sub
Private Sub OptionButton2 Click()
setoption
End Sub
Private Sub OptionButton3 Click()
setoption
End Sub
Sub setoption()
Dim c As Control
For Each c In Controls
If TypeOf c Is MSForms.OptionButton Then
If c Then
Range("A1") = c.Tag
Exit For
End If
End If
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Option Button and forms

Try telling it which userform:

Private Sub OptionButton1 Click()
setoption Userform2
End Sub
Private Sub OptionButton2 Click()
setoption Userform2
End Sub
Private Sub OptionButton3 Click()
setoption Userform2
End Sub
Sub setoption(Uform as Object)
Dim c As Control
For Each c In Uform.Controls
If TypeOf c Is MSForms.OptionButton Then
If c Then
Range("A1") = c.Tag
Exit For
End If
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"paradise" wrote in message
om...
I am having problems with MSForms.OptionButton Function.
I have 5 userforms, and in each form there are 5 option buttons of
which the user select one. The program will need to trace the option
chosen and input it into a worksheet.I have used the below stated code
but it doesn't work for userform 2, 3, 4, and 5. It seems to be able
to work for the first form-userForm1. Any help is appreciated.

Private Sub OptionButton1 Click()
setoption
End Sub
Private Sub OptionButton2 Click()
setoption
End Sub
Private Sub OptionButton3 Click()
setoption
End Sub
Sub setoption()
Dim c As Control
For Each c In Controls
If TypeOf c Is MSForms.OptionButton Then
If c Then
Range("A1") = c.Tag
Exit For
End If
End If
Next
End Sub



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
Insert comments on Option Button of Forms Toolbar Rechie Excel Discussion (Misc queries) 2 March 14th 10 11:26 AM
Option Box - Forms help Excel Discussion (Misc queries) 9 November 3rd 06 12:21 AM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
the Forms option in excel itself raw Excel Discussion (Misc queries) 0 November 4th 05 07:17 PM
Option Button on Forms Toolbar admannj Excel Discussion (Misc queries) 4 January 25th 05 01:07 AM


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