Discussion Locked

VBA/Excel - auto run a macro

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm new to VBA and I want to have a macro auto-run when ever a certain Excel workbook is opened. The macro I created works but I don't know how to automate it. I would also need to run a similar marco when that workbook is closed. Can anyone helpme?

Please respond to CBDepadua@laneconstruct.com

7 replies

by syscokid

Name your macro Auto_Open. It will run when the workbook is opened. I don't know about closing though.

by cbdepadua

This caused Exel to run the macro when it was opened in general. I would like to have the macro run only when a certain .xls file is opened. How would this change your answer?

by tclere

You can also use the Workbook_Open event. Just open the ThisWorkbook module from your VBA editor. The Auto_Open and Auto_Close subs were used in earlier versions that did not utilize the Workbook Open and Close events.

This discussion is closed to new replies.