Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default 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".
  #5   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I stop the close method in an auto close macro Paul Excel Programming 2 November 17th 06 02:48 PM
Don't let user close. Use macro button to close? mike Excel Programming 2 October 30th 06 01:31 PM
Do I have to close an odc in a macro? Tachikrusher Excel Programming 2 March 3rd 06 02:23 AM
Run Macro on close Donnie Excel Programming 6 August 29th 05 09:42 PM
Macro Close 2 Ronbo Excel Programming 1 May 5th 04 10:11 PM


All times are GMT +1. The time now is 02:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"