Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifying the name an Excel file is saved as

Status
Not open for further replies.

sunshaman

Technical User
Apr 27, 2008
1
NZ
Hi Guys

I really need some help with MAcros in Excel

I need to create a macro which when activated on the open Excel file, Saves the file under a new name (in a specific folder), the file name is pulled from three fields in the Excel sheet.

Your help is much appreciated,

David
 
Turn on the macro recorder (Tools > Macro > Record New Macro) and step through saving the file using Save As.

That will be the basis of your code.

Add to what is generated to change the file name. You can build strings like this:

strSaveAsName = Sheets(1).range("A1") & Sheets(1).range("B1") & Sheets(1).range("C1") & "_" & format(now(), "yyyymmdd") & ".xls"

(That last bit adds today's date at the end of the file name)

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Does this need to work for any file or one specific file

If it is for any file, you will need to be careful about where the macro is located - Personal.xls is your best option

Sounds a bit like a homework question though......

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top