Save Spreadsheet As 2 or 3 cell values

V

Vic49

I would like to automatically name the the file with some static text and
thevalues from 2 or 3 cells. For example:

I am creating a expense account and I would like the the name to be:
XYZ_Expenses_"Date"_"Amount"

Where:
XYZ_Expenses is Static test,
Date is located in cell J3,
Amount is located in cell J30

I am not very familiar with using or building macros, so any information on
how to build and run the macro and would be greatly appreciated. Thanks in
advance.

Win XP and Excel 2007
 
G

geoff_ness

I would like to automatically name the the file with some static text and
thevalues from 2 or 3 cells. For example:

I am creating a expense account and I would like the the name to be:
XYZ_Expenses_"Date"_"Amount"

Where:
XYZ_Expenses is Static test,
Date is located in cell J3,
Amount is located in cell J30

I am not very familiar with using or building macros, so any information on
how to build and run the macro and would be greatly appreciated. Thanks in
advance.

Win XP and Excel 2007

I'd recommend naming the cells J3 and J30 as Date and Amount
respectively (Formulas->Define Name). Then try something like the
following:

Sub Rename()
Dim wbkToBeSaved as Workbook
Dim sOldName as String
Dim sDate as String
Dim sAmount as String
Dim sNewName as String
Const sPREFIX = "XYZ_Expenses_"

' Get the workbook you want to rename
sOldName = "" ' Whatever the old name is...
Set wbkToBeSaved = Workbooks(sOldName)

' Build new name
sDate = wbkToBeSaved.Names("Date").RefersToRange.Text
sAmount = wbkToBeSaved.Names("Amount").RefersToRange.Text
sNewName = sPREFIX & sDate & "_" & sAmount

wbkToBeSaved.SaveAs sNewName

End Sub

HTH
Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top