ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run macro on close (https://www.excelbanter.com/excel-programming/445312-run-macro-close.html)

Fawn Lagimodiere

run macro on close
 
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



GS[_2_]

run macro on close
 
Please do not repost the same Q (in the same words OR other words)!!!

See the reply in your other post.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



Gord Dibben[_2_]

run macro on close
 
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


Auric__

run macro on close
 
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.


As Garry said, the copying problem is already addressed.

To run code when a workbook closes, open the workbook's class in the VBA
editor and add this sub:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'your code here
End Sub

--
I believe the official cause was listed as
"death from superior firepower".

Gord Dibben[_2_]

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



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

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