Save as file name

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
Hi,
I know this has been answered in different ways , but I still can't figure it out.

I want to save "Dashboard-Template" to "Dashboard-11-30-05" it is in the same directory. In cell "B3" of my Instruction sheet in my workbook the user can update the date, and I want the Macro to use that cell. I have recorded the following Macro but how do I refer th the cell "B3"?

Sub Save()
'
' Save Macro
' Macro recorded 11/30/2005 by CONMHI
'

'
ChDir "S:\Acctg\CGIT\Management Summaries\FY2006"
ActiveWorkbook.SaveAs filename:= _
"S:\Acctg\CGIT\Management Summaries\FY2006\DashBoard-Template.xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

"S:\Acctg\CGIT\Management Summaries\FY2006\DashBoard-Template.xls", This is where I want it to say Dashboard-B3

Thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Try:
Code:
"S:\Acctg\CGIT\Management Summaries\FY2006\DashBoard-" & Range("B3").Value & ".xls"
 
Upvote 0

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,885
Office Version
  1. 365
Platform
  1. Windows
What's the correct name of the sheet containing B3?

edit:

Sorry Kristy - didn't see you there!!
 
Upvote 0

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
I get a runtime error 1004.

" Microsoft excel cannot access the file S:\acctg\cgit\management summaries\fy2006\Dashboard-11-30-05

The file path does not exist....

Hmmm I formatted the cell to custom mm-dd-yyyy and the date shows as 11-30-2005, however in the macro it still points to 11/30/2005
 
Upvote 0

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
The correct name of the sheet is "Instruction". I would like to save the whole workbook not just the sheet.

Thanks
 
Upvote 0

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Sykes was simply asking what sheet contains the value you want to use. With your current code, it will use the value of B3 from the whatever sheet is active at the time the code runs :)

As to your question: changing the format of the date in the cell won't help--you'll need to format it in the code.

In place of Range("B3").Value, use
Code:
Format(Sheets("Instruction").Range("B3").Value, "mm-dd-yy")
 
Upvote 0

Forum statistics

Threads
1,195,594
Messages
6,010,628
Members
441,558
Latest member
lambierules

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
Top