Re: Creating a form with option buttons
- From: "Norman Jones" <normanjones@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 14 Apr 2006 03:03:51 +0100
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" <JonABurgess@xxxxxxxxx> wrote in message
news:1144976586.868476.118950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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!
.
- References:
- Creating a form with option buttons
- From: Jon
- Creating a form with option buttons
- Prev by Date: Re: Shape instead of Target
- Next by Date: Re: exception to MsgBox
- Previous by thread: Creating a form with option buttons
- Next by thread: Re: Creating a form with option buttons
- Index(es):