Excel 2000 - Automatic start up of Macro

  • Thread starter Thread starter Abay
  • Start date Start date
A

Abay

I am pretty much a newbie at Excel (don't use it as much as I would lke to
be able to). Is there a way to start up a macro when a particular
spreadsheet is opened ... I don't want this macro to start on all opened
spread sheets. I know I do I can do that, but can't find out anywhere so
far that tells me I can start up a macro when I open a particular
spreadsheet.

Any help with this would be much appreciated.

Abay
 
You can put your code behind the ThisWorkbook module and name it
workbook_open().

Or you can put your code behind a general module and call it Auto_Open().
 
Yes. The procedure is a little different depending on whether you're opening
an Excel workbook (which is the usual term for the full file, such as
2005.xls) or whether you're activating a worksheet in a workbook.

To cause a macro to run when you open a workbook, do this, with that
workbook already open:

1. Choose Tools | Macro | Visual Basic Editor. You should see a window with
a title bar that says Project Explorer.
2. In that window you'll see a reference to your workbook with a list of
objects below it (your worksheets) as well as another object called
ThisWorkbook.
3. Right click ThisWorkbook and choose View Code from the new menu.
4. Another window appears -- a code window. Click the lefthand dropdown, the
one with General selected. Choose Workbook from the dropdown.
5. You'll get a sub named Workbook_Open. Between its Sub and End Sub
statements, type the name of the procedure you want to run when you open the
workbook. Save the workbook, close it and re-open to test it.

If you want a macro to run when you activate a worksheet, right click on the
worksheet's tab and choose View Code. This will take you back to the VBE and
give you a new code window.

Now choose Worksheet from the lefthand dropdown, and the Activate item from
the righthand menu. Again, call the procedure you want to run between the
new Sub and End Sub statements.
 
Back
Top