macro

G

George Hanna

looking for the command to automate a macro to run on
worksheet open and on close
 
J

J.E. McGimpsey

If you call your macro from the Workbook_Open() event it will fire
when the workbook opens:

Private Sub Workbook_Open()
MyMacro
End Sub

This needs to be put in the ThisWorkbook code module, with MyMacro
in a regular code module. To fire before close (also in the
ThisWorkbook code module):

Private Sub Workbook_BeforeClose(Cancel As Boolean)
MyOtherMacro
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top