Hi excel experts,
I am new to VBA and have a really limited knowledge so please bare with me.
I am trying to have option buttons on my user form determine which macro to run. There are three options (call them option1, option2, option3) and three corresponding macros (lets call them macro1,
I have found online this template code:
Userform.hide
'------------------------------
if (Userform.Opt_Macro1.value) then
'(run Macro associated with Macro 1)
elseif (Userform.Opt_Macro2.value) then
'(run Macro associated with Macro 2)
elseif (Userform.Opt_Macro3.value) then
'(run Macro associated with Macro 3)
end if
'------------------------------
Unload Userform
I am not sure how to make it work for my example.
I have assigned the options separate names (option1, option2, option3) and a group name for all (OptionAll)
My Userform is named AddDataForm.
So I have:
Private Sub CommandButton2_Click()
UserForm.Hide
'------------------------------
If (UserForm.Opt_Option1.Value) Then
Run (Macro1)
ElseIf (UserForm.Opt_Option2.Value) Then
Run (Macro2)
ElseIf (UserForm.Opt_Option3.Value) Then
Run (Macro3)
End If
'------------------------------
Unload UserForm
End Sub
Where am I going wrong here??
Thanks in advance...
Bookmarks