macro save file with specific name

Beatrice

Board Regular
Joined
Sep 17, 2019
Messages
85
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone, I am very new to Marco, it would be glad to get some help here :)

Here is my trial:


DD = Day(Date)
MMM = Month(Date)
YY = Year(Date)
WBK = "S:\Project" & Format(Now, "DD MMM YY") & ".xlsx"

Windows("Destination File.xlsx").Activate
ActiveWorkbook.SaveAs Filename:=WBK, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close


So far, it is working. But I would like to add a cell value into the file name.
Example: Cell A2 = "Item Code"
I am expecting the file to be save as " S:\Project\Item Code - 28 Oct 19.xlsx"

Can anybody give me a hand?
Thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Insert A2 in between like this:

WBK = "S:\Project" & A2 & Format......
 
Last edited:
Upvote 0
Need a back-slash after the word "Project". I don't know why the web site kept removing it.
 
Last edited:
Upvote 0
Thank you for the tips! I got it now~

WBK = "S:\Project" & Range("A2") & Format(Now, "DD MMM YY") & ".xlsx"
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,532
Members
449,169
Latest member
mm424

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