Saving a worksheet with a name derived from a cell

massimo

New Member
Joined
Sep 28, 2002
Messages
3
I have an excel template which is used as an invoice. Based on the entries in three cells; "sales person", "company name", "date". I want to save to a particular directory and the file name should be e.g. c:/invoices/sales person-company-date.xls. depending on what was entered into the relevant cells.
I can create a string linking all these together but can't get the save as part to work. Can anyone help?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This code was written by Barrie Davidson, I modified it to your needs, I think, give it a try.

Sub Save_by_Cell_Valve()
'Will save the sheet to C:/invoices and name it what is in cell A1
Application.ScreenUpdating = False
Dim saveName As String
saveName = (Range("A1").Value)
ActiveWorkbook.Sheets.Select
Sheets.Copy
ActiveSheet.Activate
ChDir "c:/invoices"
ActiveWorkbook.SaveAs (saveName)
ActiveWorkbook.Close
ActiveSheet.Select
Application.ScreenUpdating = False
End Sub
 
Upvote 0
I too, have the need for this feature. However, I cannot get it to save as TODAY() as the dating format in the formula bar is mm/dd/yy and the "/" is not accepted for file names. I need the file to be named as the date it was saved.

Any suggestions?

Thanks for a great forum!!!
 
Upvote 0
try this:
=text(today(),"mm_dd_yyyy")

_________________
Oh, you hate your job? Why didn't you say so? There's a support group
for that. It's called EVERYBODY, and they meet at the bar. - Drew Carey
This message was edited by zzydhf on 2002-10-01 12:19
 
Upvote 0

Forum statistics

Threads
1,218,620
Messages
6,143,520
Members
450,492
Latest member
Rusbus1972

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