save to a area & create a backup too

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
hi,

I would like a macro to save the file in c:\data\data123 & create create a backup too in c:\data\backup\data123_backup.

is this possible?
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
.
Code:
Option Explicit


Public Sub SaveWB()
    ThisWorkbook.SaveAs Filename:="[COLOR=#333333]C:\data\data123\[/COLOR]" & ThisWorkbook.Name 
    ThisWorkbook.SaveAs Filename:="[COLOR=#333333]C:\data\backup\data123_backup[/COLOR]\" & ThisWorkbook.Name
End Sub
 
Last edited:
Upvote 0
.
Code:
Option Explicit


Public Sub SaveWB()
    ThisWorkbook.SaveAs Filename:="[COLOR=#333333]C:\data\data123\[/COLOR]" & ThisWorkbook.Name 
    ThisWorkbook.SaveAs Filename:="[COLOR=#333333]C:\data\backup\data123_backup[/COLOR]\" & ThisWorkbook.Name
End Sub


morning [FONT=&quot]Logit,

many thanks for you help.
The user wants to save to :-

[/FONT]
H:\Asset

[FONT=&quot]and the backup to:-
[/FONT]
H:\Asset\Backup

[FONT=&quot]I altered the path in your code to:-
Code:
[/FONT][/COLOR]  ThisWorkbook.SaveAs Filename:="H:\Asset" & ThisWorkbook.Name[COLOR=#201F1E][FONT=&quot]
[/FONT][/COLOR]
    ThisWorkbook.SaveAs Filename:="H:\Asset\Backup" & ThisWorkbook.Name[COLOR=#201F1E][FONT=&quot]

but although it goes through the motaions ( no erros received ) it does not work?

any suggs ?



[/FONT]
 
Upvote 0
.
Note the \ at the end of the path ...

Code:
ThisWorkbook.SaveAs Filename:="H:\Asset\" & ThisWorkbook.Name


    ThisWorkbook.SaveAs Filename:="H:\Asset\Backup\" & ThisWorkbook.Name
 
Last edited:
Upvote 0
Thank you Logit,

works a treat:}

happy days are here again!!!
 
Upvote 0

Forum statistics

Threads
1,214,791
Messages
6,121,611
Members
449,038
Latest member
apwr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top