+ Reply to Thread
Results 1 to 4 of 4

Userform/Module

  1. #1
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241

    Userform/Module

    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 these programs. What I am trying to do is to use one user from with option buttons to choose a program to run. how can I write the code to choose a specifice module when a button is sellected?
    Appreciate your help.
    Thanks
    Syed

  2. #2
    Rowan Drummond
    Guest

    Re: Userform/Module

    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


    saziz wrote:
    > 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 these
    > programs. What I am trying to do is to use one user from with option
    > buttons to choose a program to run. how can I write the code to choose
    > a specifice module when a button is sellected?
    > Appreciate your help.
    > Thanks
    > Syed
    >
    >


  3. #3
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241
    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

  4. #4
    Rowan Drummond
    Guest

    Re: Userform/Module

    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

    saziz wrote:
    > 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
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1