View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben[_2_] Gord Dibben[_2_] is offline
external usenet poster
 
Posts: 621
Default run macro on close

Taking your subject heading of "run macro on close" literally.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
code to copy, insert and paste
Thisworkbook.save
End Sub

Entered in Thisworkbook module.


Gord



On Sat, 28 Jan 2012 09:31:09 -0800, Gord Dibben
wrote:

Your description leaves ambiguity as to what your needs are.

Do you want to loop through each of 50 files, copy something, insert a
new sheet and paste then close, presumably after saving?

Or just need code in each workbook that runs on closing that workbook?



Gord

On Sat, 28 Jan 2012 09:51:51 -0700, "Fawn Lagimodiere"
wrote:

I have a 50 files and I want it to run a macro to copy and paste to new
sheet in the file on closing the document.

Is there a code to run this process.

thanks