+ Reply to Thread
Results 1 to 5 of 5

Loading userform mid routine

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    United Kingdom
    MS-Off Ver
    Office 2010
    Posts
    71

    Loading userform mid routine

    Hi

    I have a macro which when it is run activates a worksheet, I've made a userform with two buttons (one for each dashboard), how do I get Excel to open the correct sheet?

    Sort of like
    Select Case Which Button Did You Press?
    Case CommandButton1
    Open Sheet1
    Case CommandButton2
    Open Sheet2
    End Select

    Can anyone help?

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loading userform mid routine

    Hi there,

    Just have the desired sheet to be opened attached to each button, ie for Sheet1 assign this to the relevant button:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    United Kingdom
    MS-Off Ver
    Office 2010
    Posts
    71

    Re: Loading userform mid routine

    I know how to select the sheet, but how do I get from the macro running to loading the form and knowing the macro which button has been pressed?

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loading userform mid routine

    how do I get from the macro running to loading the form
    The following will open a user form called UserForm1:

    Please Login or Register  to view this content.
    just change the user form name to what your form is called and put the line of code wherever you want the form to open.

    knowing which button has been pressed
    You said you separate buttons so just assign the code to open the relevant sheet for that button You can always get a list of the visible sheets (which you then can select by clicking one) in a workbook by right-clicking the tab navigation buttons in the bottom left-hand corner of any workbook.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Loading userform mid routine

    You could put this in the Userform's code module
    Please Login or Register  to view this content.
    OH, the buttons are on the user form.
    Then each button will have its own Click event and you code the sheet in the appropriate Click event.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combo Box in userform not loading
    By sentinela in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2009, 11:40 AM
  2. Loading userform
    By tian0020 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2007, 01:57 AM
  3. Loading a Userform
    By Jason Zischke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2006, 04:40 AM
  4. Loading Userform
    By Steven Cheng in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2005, 03:20 PM
  5. [SOLVED] Loading UserForm gives error
    By Mats Samson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2005, 04:05 AM

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