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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Paul B

Well-known Member
Joined
Feb 15, 2002
Messages
575
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
 

JimB

Board Regular
Joined
Sep 19, 2002
Messages
81
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!!!
 

zzydhf

Board Regular
Joined
Apr 10, 2002
Messages
236
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
 

Forum statistics

Threads
1,144,218
Messages
5,723,069
Members
422,477
Latest member
pete101

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