Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to create a user form that has 4 option buttons and an ok button
to close the form. i have gotten the ok button to work fine with Private Sub OK_Click() Unload UserForm1 End Sub but now i want to make the 4 option buttons set a variable to either 1,2,3, or 4. How can I do this? Do i need code in the private sub for the button or in my main code? Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jon,
In a standard module, before any code, paste: Public myVar As Long Then, in the userform module, try: '============= Private Sub OptionButton1_Click() myVar = 1 End Sub Private Sub OptionButton2_Click() myVar = 2 End Sub Private Sub OptionButton3_Click() myVar = 3 End Sub Private Sub OptionButton4_Click() myVar = 4 End Sub '<<============= If you wish to reset the myVar variable each time that the form is opened, try: '============= Private Sub UserForm_Initialize() myVar = 0 End Sub '<<============= This should be pasted in the userform module. --- Regards, Norman "Jon" wrote in message oups.com... I need to create a user form that has 4 option buttons and an ok button to close the form. i have gotten the ok button to work fine with Private Sub OK_Click() Unload UserForm1 End Sub but now i want to make the 4 option buttons set a variable to either 1,2,3, or 4. How can I do this? Do i need code in the private sub for the button or in my main code? Thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without knowing more, possibly:
Public v as Integer Private Sub OptionButton1_Click() v = 1 End Sub Private Sub OptionButton2_Click() v = 2 End Sub Private Sub OptionButton3_Click() v = 3 End Sub Private Sub OptionButton4_Click() v = 4 End Sub -- Regards, Tom Ogilvy "Jon" wrote in message oups.com... I need to create a user form that has 4 option buttons and an ok button to close the form. i have gotten the ok button to work fine with Private Sub OK_Click() Unload UserForm1 End Sub but now i want to make the 4 option buttons set a variable to either 1,2,3, or 4. How can I do this? Do i need code in the private sub for the button or in my main code? Thanks! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. My error was that I did not define the variable as public.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
form option buttons - how can I make them accessible? | Excel Discussion (Misc queries) | |||
Option Buttons in a Form | Excel Discussion (Misc queries) | |||
option buttons in a form | Excel Programming | |||
User Form Option & Command Buttons | Excel Programming | |||
2 sets of option buttons on one user form? | Excel Programming |