+ Reply to Thread
Results 1 to 5 of 5

Macros Not Running in Correct Workbook

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Macros Not Running in Correct Workbook

    Hi! I have six reports that need to be created either daily or weekly. Rather than manually opening each workbook separately to run the macros and create the reports, I'd like to create a single workbook (a master macros workbook) with six form buttons, one to open and run the macros for each separate report.

    However, the problem I'm encountering is that instead of the macros running within the workbooks where they reside, they are trying to run within the master macros workbook. This is obviously not producing the desired results and the macros are crashing. Also, the macros within the workbooks are running immediately on opening, even without explicit code to tell them to do so. I have seen somewhere that this is a normal function when an .xlsm workbook is opened like this, however.

    Can anyone help me understand how to prevent this from happening and for the macros to run within their own workbook? Here is the very minimal code I have so far for just one form button:

    Please Login or Register  to view this content.
    Thanks!

    Bryan

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros Not Running in Correct Workbook

    Perhaps if you move this to the Workbook_Open event??

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Macros Not Running in Correct Workbook

    Thanks for your reply, XLAdept. Sorry it took so long to get back to you. Unfortunately, that code didn't seem to help, but perhaps it's because I'm not familiar with the Private Sub. I'll have to look into that when I have time.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros Not Running in Correct Workbook

    That code would go in the "ThisWorkbook" module.

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Macros Not Running in Correct Workbook

    Yes, I found that out after doing some searching on the internet, and placed your code there. Unfortunately, there was no change to the macros' performance I'm still getting the same error.

+ 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. [SOLVED] problems running macros on more than one sheet in a workbook
    By bite_tony in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-15-2013, 12:02 PM
  2. running 2 macros in a shared workbook
    By thuddleston11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2012, 08:14 AM
  3. running macros on workbook open
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2009, 09:09 AM
  4. Running Macros from a separate Workbook
    By Rabi in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2008, 08:13 AM
  5. Running Macros in protected workbook
    By petunia in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-18-2005, 06:06 PM

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