Save a file based on filename

francozola25

Board Regular
Joined
Aug 22, 2007
Messages
96
Is there any way in Excel VBA. that i could have a macro that will save a file off based to an E:\Drive based on it's filename?

The E:\Drive is a USB drive, i just want to back up my data on USB drive this way.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Can you explain what it is you want to do - I have failed to understand. Are you just wanting ot save the file to the E drive? If so, why is this causing you problems?
 
Upvote 0

francozola25

Board Regular
Joined
Aug 22, 2007
Messages
96
The file is updated everyday, at the end of the evening, i the macro to be able to take the filename and copy to the E:\Drive when a button is clicked. As long with the filename is there a way to include todays date in the file save as?
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Sure:

Code:
Dim strMyFile As String
strMyFile = ThisWorkbook.Name
ThisWorkbook.SaveAs "E:\myFolder\" & Left(strMyFile,InstrRev(strMyFile,".")-1) & Format(Date,"yyyy-mmm-dd") & ".xls"

which will save the file down with today's date appended as "2008-Jun-24.xls"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,190,889
Messages
5,983,402
Members
439,843
Latest member
PlanetFitness

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
Top