Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home

Let macro perform an action on 'excel close'

Posted by Remi on January 31, 2002 1:21 AM
hey, I`m building a macro which has to copie a few cell to another .xls file. This copying however, must take place when the first file is being closed.

How do I get this done? My approach would be: record a macro for the parts that are done within the first file. Then get into this macro and edit it. But it is virtually impossible to search for what I`m looking for via a keyword.

Hope someone can help me!
tnks.

Remi
Holland.


Check out our Excel VBA Resources

Re: Let macro perform an action on 'excel close'

Posted by Jim on January 31, 2002 5:35 AM
Record the macro and place it into the "ThisWorkbook" object under sub Workbook_BeforeClose


record a macro for the parts that are done within the first file. Then get into this macro and edit it. But it is virtually impossible to search for what I`m looking for via a keyword.


Re: Let macro perform an action on 'excel close'

Posted by Carl B on January 31, 2002 7:22 AM
In VBA under Workbook insert this
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbook("Filename and path here").Worksheets("name Of Sheet here") = ActiveWorkbook.Worksheets("name of sheet to copy from").Range("cell range here")
End Sub record a macro for the parts that are done within the first file. Then get into this macro and edit it. But it is virtually impossible to search for what I`m looking for via a keyword.


Re: Let macro perform an action on 'excel close'

Posted by Remi on February 01, 2002 12:23 AM

THANK YOU ALL! Gonne use your tips.


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.