Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Userform (Excel 2000)

    Question,

    If I have a number of forms in the same project, does every userform need a macro to show and hide it? Is there a way to call one macro, and display that form?

    Thanks, Darryl.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Userform (Excel 2000)

    Sorry, I don't understand. What do you mean by "Is there a way to call one macro, and display that form?" Which form?

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Userform (Excel 2000)

    As far as I can envisage, you will need a separate macro for each form to show it, usually just:
    UserFormN.Show

    but when it comes time to hide it, that should be done from within the code for that particular form, usually in association with the click of an "OK" or "Cancel" etc. button, when processing is completed. Can you give a particular example of the situation you're contemplating?

    Alan

  4. #4
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Userform (Excel 2000)

    My project doesn't have 50 userforms, just 3, instead of using a prodcedure everytime you show it.

    Public Sub Showit()
    Load Userform1
    userform1.show
    end sub

    If I had 50 forms in the project would there be a way to call this procedure to display the current form? instead of writing 50 procedures to show the form?

    Thanks, Darryl.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Userform (Excel 2000)

    I still don't understand. What is the "current form"?

  6. #6
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Userform (Excel 2000)

    When showing a userform from another form what I usually do is call a sub on the click event.
    Commandbutton1_click
    If commandbutton1.value = true then
    Call Showit()

    End if
    End sub


    Public Sub showit()
    load userfom1
    userform1.show
    end sub

    Is it possible to have a Userform as a variable, and use a function to show the form?

    call showit(something in here.)?

    Thanks, Darryl.......Just a question cause I'm trying to figure something out about Functions and Procedures <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Userform (Excel 2000)

    Hi Darryl,
    Yes you can - something like:
    <pre>Sub ShowForm(strFormName As String)
    VBA.UserForms.Add(strFormName).Show
    End Sub
    </pre>

    which you then call with something like:
    <pre>Showform "formname"</pre>

    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Userform (Excel 2000)

    Thank you all....

Posting Permissions

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