File naming using cell reference

constructor_ac

New Member
Joined
Aug 7, 2002
Messages
2
Please help me with the syntax to reference a cell's contents when saving a file. I want to write a macro that will automatically save a file with a file name that is a combination of two cells in my spreadsheet.

So far I have:
ActiveWorkbook.SaveAs Filename:= _"C:(Reference Cells F2+F5 Here).xls"

What do I insert into ( ) above to make th filename reference Cells F2 and F5 and combine the two into a single filename?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I assume you mean the value of the cells (the contents) that will serve as parts of filename, separately - not as a sum of 2 values. Try this:

Code:
Sub save()

With ThisWorkbook.Worksheets("Sheet1")
ThisWorkbook.SaveAs Filename:="d:" & .Range("F2").Value & .Range("F5").Value & ".xls"
End With

End Sub

Also this assumes that the code is within the file being saved. Naturally, you need to change "Sheet1" to the worksheet name.

Hope this helps.

P.S. there is only 1 backslash - the other gets inserted by the webpage.

To boardmaster people: Why does this keep happening? It is rather annoying and confusing
This message was edited by Dragon_SDC on 2002-08-23 15:58
 
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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