ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code to save to 2 locations (https://www.excelbanter.com/excel-programming/313389-vba-code-save-2-locations.html)

Sinjin341[_4_]

VBA Code to save to 2 locations
 

I currently have code to save my workbook after running a couple o
procedures. I would also like to save the workbook to another locatio
as a backup on a different drive. Is it possible to save a workbook t
multiple locations in the same code set? Below is the code I alread
have.


Sub moverange()
x = Cells(Rows.Count, "A").End(xlUp).Row + 1
range(Cells(x, "A"), Cells(x + 0, "H")).Value
range("New_Entry").Value
range("New_Entry").Select
Selection.Clearcontents
range("A2").Select
ActiveWorkbook.Save
End Sub

Thank you,
Sinjin34

--
Sinjin34
-----------------------------------------------------------------------
Sinjin341's Profile: http://www.excelforum.com/member.php...fo&userid=1461
View this thread: http://www.excelforum.com/showthread.php?threadid=26882


Tom Ogilvy

VBA Code to save to 2 locations
 
to save to the second location (this avoids changing the activeworkbook to
the backup copy)

range("A2").Select
ActiveWorkbook.Save
Application.DisplayAlerts = False
Activeworkbook.SaveCopyAs "C:\MyBackupFolder\" & ActiveWorkbook.Name
Application.DisplayAlerts = True

This overwrites a previous backup (with the same name) without prompt.

--
Regards,
Tom Ogilvy

"Sinjin341" wrote in message
...

I currently have code to save my workbook after running a couple of
procedures. I would also like to save the workbook to another location
as a backup on a different drive. Is it possible to save a workbook to
multiple locations in the same code set? Below is the code I already
have.


Sub moverange()
x = Cells(Rows.Count, "A").End(xlUp).Row + 1
range(Cells(x, "A"), Cells(x + 0, "H")).Value =
range("New_Entry").Value
range("New_Entry").Select
Selection.Clearcontents
range("A2").Select
ActiveWorkbook.Save
End Sub

Thank you,
Sinjin341


--
Sinjin341
------------------------------------------------------------------------
Sinjin341's Profile:

http://www.excelforum.com/member.php...o&userid=14616
View this thread: http://www.excelforum.com/showthread...hreadid=268820




Bob Flanagan

VBA Code to save to 2 locations
 
One way:

ActiveWorkbook.SaveCopyAs "C:\book2.xls"

saves it as a backup copy and does not change the active file to a new
filename.

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Sinjin341" wrote in message
...

I currently have code to save my workbook after running a couple of
procedures. I would also like to save the workbook to another location
as a backup on a different drive. Is it possible to save a workbook to
multiple locations in the same code set? Below is the code I already
have.


Sub moverange()
x = Cells(Rows.Count, "A").End(xlUp).Row + 1
range(Cells(x, "A"), Cells(x + 0, "H")).Value =
range("New_Entry").Value
range("New_Entry").Select
Selection.Clearcontents
range("A2").Select
ActiveWorkbook.Save
End Sub

Thank you,
Sinjin341


--
Sinjin341
------------------------------------------------------------------------
Sinjin341's Profile:

http://www.excelforum.com/member.php...o&userid=14616
View this thread: http://www.excelforum.com/showthread...hreadid=268820





All times are GMT +1. The time now is 02:20 PM.

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