Run macro when file closes

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
P

Patrick C. Simonds

I need to run a macro every time my workbook close. Can this be done?
 
in the vb editor, double click the "thisworkbook" entry under microsoft excel
objects and select workbook from the dropdown and then before close from the
event dropdown

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' your macro
End Sub

or use

sub auto_Close()
' your macro
end sub

in a general module
 

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

Back
Top