Creating a new file and naming it with text and cell reference

3129zientya

New Member
Joined
Aug 26, 2011
Messages
2
Hi,

I am trying to create a macro that will create a new excel file that will be named : Hub Date.xls

Date needs to come from a certain cell that will change dates and Hub will always remain the same (there is no way to reference the hub cell because the location will always change)

Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I might not be total clear on what you meant by "date needs to come from certain cell" when later you say "cell locations changes". But, if the date is always in, for example A1, and its already in text format...

Sub test()

sFile = "Hub_" & Worksheets("SomeSheet").Range("A1").Value & ".xls"


End Sub

Or you many need to format the date as text first:

Sub test()

YourDt= Format(Range("A1").Value , "yyyymmdd")
sFile = "Hub_" & YourDt & ".xls"



End Sub
 
Upvote 0
Welcome to the Board!

ActiveWorkbook.SaveAs Filename:="Drive:\Path\Hub " & Sheets("Sheet1").Range("A1").Value & ".xlsm"

If you're referencing a date you'll need to use Format to set the style to be valid for a file name (i.e. no "/"'s)

You can record a macro performing a save as to get the path you want.

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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