VBA - Save file - rename and move original file

dnorm

Board Regular
Joined
Dec 28, 2017
Messages
125
Office Version
  1. 365
Platform
  1. Windows
Hi All

I am looking to see if you check and move an old file andrename it before overwriting it with the current file (archiving past reports whilemaintaining short cuts for those who need it). Save strings/path I can set upto a cell reference. I need help with looking for and moving old files. The instructionsI hope to flow something like this:
i.e.
If report.xlsb is @ string1 then
report.xlsb (OLD) @ string1 move
save as report(D1).xlsb @ string2
if not report.xlsb save to string1
report.xlsb (current) save to string1
replace true
Report= file name (derived from cell F1)
String1= path (derived from cell G2)
String2= path2 (derived from cell H2)
D1= date cell for year reference
My plan is string1 and string2 will be unique to each varianceof the report, but the report is universal for all variants (10 cars, historyfor each car, but all cars have own reports).
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
For me it's not complety clear want you want to do, if there are only one report.xlsb in the folder just use...
Code:
year = range("D1")
N[/FONT][/COLOR][COLOR=#000000][FONT='inherit']ame [/FONT][/COLOR][COLOR=#000000][FONT='inherit']"report.xlsb" [/FONT][/COLOR][FONT='inherit'][B]As [/B][/FONT][COLOR=#000000][FONT='inherit']"report(" & year & ").xlsb"[/FONT][/COLOR]

If there are several files you need to loop trough the folder.
 
Last edited:
Upvote 0
Hi Most
Sorry for the late reply. I am doing this to idiot proof thefiles for others to complete (fill info, click button to complete). Engineers would only need one shortcut toalways access the most recent file (no more duplicates), with all old filesbeing archived (which is why the name change).
Tech fills in template – then clicks save button
Save “Template.xls” as “Vehicle Alpha Burn Test.xls” inlocation G2.
If File “Vehicle Alpha Burn Test.xls” exists in G2 – save file“Vehicle Alpha Burn Test.xls” in G2 as “Vehicle Alpha Burn Test 2019.xls” in H2
Then save Template as “Vehicle Alpha Burn Test.xls” inlocation G2.
This will cover over 200 product tests and file locationsbased on a VLOOKUP in G2 and H2.

 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,580
Members
448,972
Latest member
Shantanu2024

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