ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Run a macro when opening a spreadsheet (https://www.excelbanter.com/excel-discussion-misc-queries/3438-run-macro-when-opening-spreadsheet.html)

Duncan Help

Run a macro when opening a spreadsheet
 
How or where do I invoke a macro when I open a spreadsheet.

dlw

name it autoexec

Norman Jones

Hi Duncan,

In the workbook's ThisWorkbook Module, insert a

Sub workbook_open()
'Your code
End Sub

macro. To access this module, right-click the Excel icon to the left of
"File" on th menu bar, select "View Code".

Alternatively, in a general module, insert a

Sub Auto_Open
'Your Code
End Sub

macro.

If you are unfamiliar with macros, see David McRitchie's Getting Started
with Macros and User Defined Functions notes at:

http://www.mvps.org/dmcritchie/excel/getstarted.htm


---
Regards,
Norman



"Duncan Help" wrote in message
...
How or where do I invoke a macro when I open a spreadsheet.




Bob Phillips


"Norman Jones" wrote in message
...
To access this module, right-click the Excel icon to the left of
"File" on th menu bar, select "View Code".


This is true if you have your spreadsheet maximized, but if you don't as in
my case, the icon is at the top-left of the spreadsheet, not by the File
menu.



Norman Jones

Hi Bob,

Thank you - I will expand the instructions in future!


---
Regards,
Norman



"Bob Phillips" wrote in message
...

"Norman Jones" wrote in message
...
To access this module, right-click the Excel icon to the left of
"File" on th menu bar, select "View Code".


This is true if you have your spreadsheet maximized, but if you don't as
in
my case, the icon is at the top-left of the spreadsheet, not by the File
menu.





Bob Phillips

Been there Norman. I think it was Gord Dibben that corrected me :-)

Bob


"Norman Jones" wrote in message
...
Hi Bob,

Thank you - I will expand the instructions in future!


---
Regards,
Norman



"Bob Phillips" wrote in message
...

"Norman Jones" wrote in message
...
To access this module, right-click the Excel icon to the left of
"File" on th menu bar, select "View Code".


This is true if you have your spreadsheet maximized, but if you don't as
in
my case, the icon is at the top-left of the spreadsheet, not by the File
menu.








All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com