Macro save a file - dynamic name

roversam

New Member
Joined
Sep 10, 2011
Messages
14
I have a file with the following data:
A1 - Information
A2 - Date
A3 - Folder

I want a macro to save the file in folder A3, with the name "[A1] [MONTH(A2)] [DAY(A2)] [YEAR(A2)]"

How do I do that?
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this.
Code:
[/FONT]
[FONT=Courier New]Sub test()
Dim myfilename As String
myfilename = Range("C2").Value & Range("A2").Value & " " & Format(Range("B2"), "MM DD YY")
ActiveWorkbook.SaveAs Filename:=myfilename & ".xlsm", FileFormat:=xlNormal
End Sub
 
Upvote 0
Code:
    Dim sPath As String
    sPath = Range("A2").Value
    
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
    ActiveWorkbook.SaveAs sPath & Range("A1").Value & Format(Range("A2").Value, " mmddyyyy")
I would use date format yyyymmdd instead ...
 
Upvote 0
:)
A1 - Information
A2 - Date
A3 - Folder


Try this.
Code:
[/FONT]
[FONT=Courier New]Sub test()[/FONT]
[FONT=Courier New]Dim myfilename As String[/FONT]
[FONT=Courier New]myfilename = Range("a3").Value & Range("A1").Value & " " & Format(Range("a2"), "MM DD YY")[/FONT]
[FONT=Courier New]ActiveWorkbook.SaveAs Filename:=myfilename & ".xlsm", FileFormat:=xlNormal[/FONT]
[FONT=Courier New]End Sub[/FONT]
[FONT=Courier New]

 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

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