Save workbook to 2 different locations macro and rename one of them

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Good Morning Everyone,

I'm trying to come up with a macro that will save a workbook in two different locations.This workbook gets used ONCE per day so for example, the original file resides on the desktop and I want to save that as the original file "C:\Users\Leasburg Front Count\Desktop\LOTTERY.XLSB" .

The 2nd part of the equation is a little stickier. I want to save that as "C:\Users\Leasburg Front Count\Dropbox\LOTTERY BACKUP\LOTTERY.XLSB"
BUT not overwrite the file from the previous save so maybe it saves as LOTTERY.XLSB(2), LOTTERY.XLSB(3), etc or what would be even better is
if we could save it as the current date so something like this LOTTERY2-25-19.XLSB OR something similar to that.

Thank you!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Re: How to save workbook to 2 different locations macro and rename one of them

Maybe:
Code:
"C:\Users\Leasburg Front Count\Dropbox\LOTTERY BACKUP\LOTTERY" & Format(Date, "mm-dd-yy") & ".XLSB"
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

Hi Mumps,

You think something like this?


Code:
Sub SaveToLocations()


 ActiveWorkbook.SaveCopyAs "C:\Users\Leasburg Front Count\Desktop\" + ActiveWorkbook.LOTTERY.XLSB
    ActiveWorkbook.SaveCopyAs ""C:\Users\Leasburg Front Count\Dropbox\LOTTERY BACKUP\LOTTERY" & Format(Date, "mm-dd-yy") & ".XLSB"
    ActiveWorkbook.Save
End Sub
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

Try:
Code:
Sub SaveToLocations()
    ActiveWorkbook.SaveAs "C:\Users\Leasburg Front Count\Desktop\" + ActiveWorkbook.LOTTERY.XLSB
    ActiveWorkbook.SaveAs "C:\Users\Leasburg Front Count\Dropbox\LOTTERY BACKUP\LOTTERY" & Format(Date, "mm-dd-yy") & ".XLSB"
End Sub
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

I didn't look at your first line of code. I have to be more careful. Try:
Code:
Sub SaveToLocations()
    ActiveWorkbook.SaveAs Filename:="C:\Users\Leasburg Front Count\Desktop\LOTTERY.XLSB"
    ActiveWorkbook.SaveAs Filename:="C:\Users\Leasburg Front Count\Dropbox\LOTTERY BACKUP\LOTTERY" & Format(Date, "mm-dd-yy") & ".XLSB"
End Sub
 
Last edited:
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

Thanks Mumps! That works great.

Question. I wasn't thinking clearly in my description.The date stamp needs to reflect the previous date if that's possible?
So today is the 25th and we are actually working on data from the 24th so if is possible we would want the backup to show "Lottery 2-24-19".

As always thanks so much!
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

Try:
Code:
Format(Date - 1, "mm-dd-yy")
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

THANKS MUMPS! That works great!

Also, wondering if you have any experience with Access. We use this workbook as a linked table in Access but I am ending up with
clutter because we don't use all of the rows in the worksheet on a daily basis so I'm looking for a way to do a select delete in an
Access table if a record is not populated based on a field.

Thanks
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

You are very welcome. :) I'm afraid that my knowledge of Access is extremely basic so I wouldn't be able to help. :(
 
Upvote 0
Re: How to save workbook to 2 different locations macro and rename one of them

MUMPS,

No worries and thanks again!
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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