Macro to correct filename syntax

brumby

Active Member
Joined
Apr 1, 2003
Messages
400
hiya all,

I have each week 6 files which I link various source data to to allow me to keep an eye on things. below is an example of week 36 and the files that are live

Airbag_Material_Plan_36.xlsm
Airbag_Material_Plan_36_AB.xlsm
Airbag_Material_Plan_36_DP.xlsm
Airbag_Material_Plan_36_MG.xlsm
Airbag_Material_Plan_36_RD.xlsm
Airbag_Material_Plan_36_TR.xlsm

However during week 36, a recovered file came into play, so the files looked like this :

Airbag_Material_Plan_36.xlsm
Airbag_Material_Plan_36_AB (version 1).xlsb.xlsm
Airbag_Material_Plan_36_AB.xlsm
Airbag_Material_Plan_36_DP.xlsm
Airbag_Material_Plan_36_MG.xlsm
Airbag_Material_Plan_36_RD.xlsm
Airbag_Material_Plan_36_TR.xlsm

If possible I would like to either run a macro or batch file to look at the files and if a recovered / autosaved version comes into play, rename and delete the previous "old" saved file so in this example :-

Airbag_Material_Plan_36.xlsm
Airbag_Material_Plan_36_AB (version 1).xlsb.xlsm - becomes "Airbag_Material_Plan_36_AB.xlsm"
Airbag_Material_Plan_36_AB.xlsm - is deleted
Airbag_Material_Plan_36_DP.xlsm
Airbag_Material_Plan_36_MG.xlsm
Airbag_Material_Plan_36_RD.xlsm
Airbag_Material_Plan_36_TR.xlsm


Is this possible?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
are there criteria that say (version 1) is the newsiest record, maaybe a date could be used so you get the newest ?
 
Upvote 0
I could include date timestamp in save name. However it's onpy really to help catch the save problems i frequently get
 
Upvote 0

Forum statistics

Threads
1,215,773
Messages
6,126,822
Members
449,341
Latest member
addman24

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