Userform/Module

  • Thread starter Thread starter saziz
  • Start date Start date
S

saziz

Hi All,
I have to dif. VBA short programs for calculating wt. conversion
temp. conversion. As of now I have two different files to run thes
programs. What I am trying to do is to use one user from with optio
buttons to choose a program to run. how can I write the code to choos
a specifice module when a button is sellected?
Appreciate your help.
Thanks
Sye
 
Copy both of your macros into module sheet/s in the same workbook, I
have called them macro1 and macro2.

Create your userform with two optionbuttons and a commandbutton. The
code in the userform would then look something like this:

Private Sub UserForm_Initialize()
Me.OptionButton1 = True
End Sub

Private Sub CommandButton1_Click()
If Me.OptionButton1 Then
Call macro1
Else
Call macro2
End If
Unload.Me
End Sub

Hope this helps
Rowan
 
Hi Rowan,
Thanks for your reply. I am trying to show userform1 or userform2, if
a specific button is clicked. As you wrote to call macro how do I get
to trigger module to show that specific userform? I hope I am clear
enough.
Thanks
Syed
 
The code to load a userform is:
UserForm1.Show

so if you are wanting this to run when a button (say commandbutton1) is
clicked then maybe:
Private Sub CommandButton1_Click()
If Me.OptionButton1 Then
userform1.show
Else
userform2.show
End If
Unload.Me
End Sub

Hope this helps
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top