+ Reply to Thread
Results 1 to 5 of 5

Run macro from another spreadsheet?

  1. #1
    Registered User
    Join Date
    09-04-2014
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    36

    Run macro from another spreadsheet?

    Hi,

    Is it possible to have a command button that is assigned to a macro in another workbook? I have a huge workbook with many formatted sheets. I currently have a dashboard in the same workbook that has multiple command buttons with each button assigned a macro that opens a specific worksheet and creates a PDF ready to print. I'd like to move that dashboard to a separate workbook.

    Thanks for any advice!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run macro from another spreadsheet?

    I suppose. What you'd be doing is having the buttons in the Dashboard workbook:

    1) Test to see if your main workbook is already open.
    2) If the workbook is not open, the macro would open it.
    3) Once the macro has detected the open workbook (1) or opened it because it was closed (2), set a wb variable to reference that workbook
    4) Proceed to process the designated worksheet from that workbook the way you do now, except be sure to add the wb reference to keep the object connected during the macro run.


    Sample snippets:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 09-18-2014 at 11:06 AM. Reason: Correction to usage of the wasOPEN variable.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-04-2014
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    36

    Re: Run macro from another spreadsheet?

    Thanks Jerry!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run macro from another spreadsheet?

    I've made a correction above to the usage of the wasOPEN variable.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    09-04-2014
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    36

    Re: Run macro from another spreadsheet?

    Thanks for all your help!

+ 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. Replies: 0
    Last Post: 05-19-2014, 04:16 PM
  2. Macro to Export Data from one spreadsheet to a Report Spreadsheet
    By stockgoblin42 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-11-2013, 03:59 PM
  3. Macro search one spreadsheet replaces in another spreadsheet
    By sarahhe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-30-2011, 09:15 PM
  4. Spreadsheet Macro
    By Kristin from NYS in forum Excel General
    Replies: 1
    Last Post: 05-05-2006, 03:00 PM
  5. Replies: 1
    Last Post: 02-08-2005, 06:06 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