ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving a single worksheet as new file before close (https://www.excelbanter.com/excel-programming/361377-saving-single-worksheet-new-file-before-close.html)

MDC[_3_]

Saving a single worksheet as new file before close
 

I am trying to get my workbook to export or save a single worksheet as
new file each time the main workbook closes . . . is this possible?
am trying to date and time stamp each newly created file as well so
can have a history of changes made on that one sheet . . . the reason
am doing this is because the workshhet is updated weekly and I woul
like to keep the past data on record instead of it being deleted eac
time someone types in a cell . . . I'm sure there is some simple cod
to do this that I am not understanding . . . thanks in advance for an
help on this matter

--
MD
-----------------------------------------------------------------------
MDC's Profile: http://www.excelforum.com/member.php...fo&userid=3439
View this thread: http://www.excelforum.com/showthread.php?threadid=54171


dmthornton

Saving a single worksheet as new file before close
 
You could add something like this in the Workbook Close event:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Sheet3.Copy
ActiveWorkbook.Close True, ThisWorkbook.Path & "\Export_" & Format(Now,
"YYYYMMDDHHMMSS")
Application.ScreenUpdating = True
End Sub

This should create a copy of the worksheet in the working folder. The name
includes a date/time stamp as well.



"MDC" wrote:


I am trying to get my workbook to export or save a single worksheet as a
new file each time the main workbook closes . . . is this possible? I
am trying to date and time stamp each newly created file as well so I
can have a history of changes made on that one sheet . . . the reason I
am doing this is because the workshhet is updated weekly and I would
like to keep the past data on record instead of it being deleted each
time someone types in a cell . . . I'm sure there is some simple code
to do this that I am not understanding . . . thanks in advance for any
help on this matter.


--
MDC
------------------------------------------------------------------------
MDC's Profile: http://www.excelforum.com/member.php...o&userid=34391
View this thread: http://www.excelforum.com/showthread...hreadid=541710




All times are GMT +1. The time now is 03:05 PM.

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