Option box for running a macro
I am almost there... I have created the UserForm with two option buttons for
the 2 macros. I seem to be missing the code which connects the selection of
the option button and running of either of the macros. At the moment the
UserForm comes up on screen, I select an option then the macro just stops.
Can you see what I am missing? Also, I'm not sure where I should put the
code. Do I have it within the UserForm as below, or should it be seperate?
Private Sub UserForm_Click()
UserForm1.Show
If OptionButton1.Value = True Then
Call Macro1
ElseIf OptionButton2.Value = True Then
Call Macro2
Else
Exit Sub
End If
End Sub
"carlo" wrote:
In that case you should consider to build your own userform.
(which sounds harder than it is.)
You should find some nice tutorials online.
If you have any problems, just ask.
Cheers
Carlo
On Nov 28, 5:14 am, Ant wrote:
Thanks for your reply. Do you know if it is possible to have a box with the
selection built in? Perhaps a drop down arrow with both choices available.
This would allow the user to simply select an option without having to type
in anything.
"JLGWhiz" wrote:
The simplest method would be the input box.
Sub opt1or2()
myOpt = Application.InputBox("Enter either a 1 or a 2.", "Pick Option",
Type:=1)
If myOpt = 1 Then
Call Macro1
ElseIf myOpt = 2 Then
Call Macro2
Else
Exit Sub
End If
End Sub
You can attach this to a button from the forms tool bar or the ToolBox tool
bar. See VBA help for using the ToolBox button.
"Ant" wrote:
I have 2 macros which I would like to combine into one. Basically I would
like the user to start the macro (push a button) and a window/balloon or
something will pop up with the choice of option 1 or option 2. Choosing
option 1 will run macro 1 and choosing option 2 will run macro 2.
Thanks in advance.- Hide quoted text -
- Show quoted text -
|