How to reverse string order in file naming macro?

MutantWizard

New Member
Joined
Mar 30, 2019
Messages
2
I have the following working well for saving files and making version backup copies in two different locations. for sorting purposes I would though like to change the order of the file name strings. File name first, date and time stamp second. Have not succeeded yet. Appreciate if anybody can advise how to do this.

Code:
Sub SaveToLocations()
    Dim datim As String
    datim = Format(CStr(Now), "yyyy_mm_dd_hh_mm_ss_")

    ActiveWorkbook.SaveCopyAs "I:\FBackupCS\" & datim & ActiveWorkbook.Name
    ActiveWorkbook.SaveCopyAs "E:\CS Docs\FBackupCS\" & datim & ActiveWorkbook.Name
    ActiveWorkbook.Save
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
try

Code:
Sub SaveToLocations()
    Dim datim As String, fName As String
    datim = Format(CStr(Now), "yyyy_mm_dd_hh_mm_ss_")
    fName = Left(ActiveWorkbook.Name, InStrRev(ActiveWorkbook.Name, ".") - 1) & " "
    fName = fName & datim
    MsgBox fName
    With ActiveWorkbook
        .SaveCopyAs "I:\FBackupCS\" & fName
        .SaveCopyAs "E:\CS Docs\FBackupCS\" & fName
        .Save
    End With
End Sub

Delete message box after testing
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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