MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Running a Macro automatically upon opening workbook

Posted by Phil D. Gonzalez on November 12, 2001 3:02 PM

Hi all,

I am sure that there must be a simple answer to this, but I have yet to find it. :(

I basically have a macro that I wish to run automatically upon opening an Excel spreadsheet. Is there any way to do this? I vaguely recalled an Autoexec function that would run whatever code is listed therein, but I have not been successful at finding any info on this.

Posted by bob umlas on November 12, 2001 5:56 PM

2 ways you can do this:
Have any sub named Auto_Open() and it'll run automatically, or use the Workbook_Open event, which you can get to by right-clicking the "X" (Excel Logo) to the left of the file menu & selecting "View Code", then drag the leftmost dropdown to "Workbook" and the workbook_open event stub will be there for you to put your code into. The latter is the "preferred" way.

Posted by Darren on November 13, 2001 7:47 AM

I am having a similar problem. I need the computer to launch Excel, and upon doing so initiate a Macro contained within the spreadsheet!! Really struggling

Posted by Phil D. Gonzalez on November 14, 2001 2:19 PM

Worked beautifully! Thank you.