Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default Save spreadsheet using cell values as filename

I am trying to use a command button to save a spreadsheet using cell values
as the file name from the tab Master. For example I want to use cells B2
(Tony.Dungate) and F2 (2010.March) to create a file name of
Tony.Dungate.2010.March.xls. Essentialy I would need something like :

Master!B2&.&Master!G2&".xls"

Can someone advise me on the correct code to do this. I have been trying to
use the following without success:


Const sRoot As String = "V:\Database Logs\"

With ActiveWorkbook
.SaveAs Filename:=sRoot & _
.Worksheets("Master").Range("B2").Text, _
FileFormat:=xlExcel8
.Close
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 32
Default Save spreadsheet using cell values as filename


In your spreadsheet can you enter in a cell say A1 or appropriate.

=B2& " "&F2 (this will result in "Tony Dungate 2010.March")

Then create the following sub.


Sub filename()

Dim Name As String
Range("A1").Select
Name = ActiveCell
ActiveWorkbook.SaveAs filename:="V:\Database Logs\" & Name & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub


You may well get some better constructed answers than this.











"Tony" wrote in message
...
I am trying to use a command button to save a spreadsheet using cell values
as the file name from the tab Master. For example I want to use cells B2
(Tony.Dungate) and F2 (2010.March) to create a file name of
Tony.Dungate.2010.March.xls. Essentialy I would need something like :

Master!B2&.&Master!G2&".xls"

Can someone advise me on the correct code to do this. I have been trying
to
use the following without success:


Const sRoot As String = "V:\Database Logs\"

With ActiveWorkbook
.SaveAs Filename:=sRoot & _
.Worksheets("Master").Range("B2").Text, _
FileFormat:=xlExcel8
.Close



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
a Macro to "save as" filename from a cell on the sheet and then pr gugertmk Excel Discussion (Misc queries) 0 March 31st 09 12:32 AM
getting values from a filename as a date in a cell Me Excel Discussion (Misc queries) 12 October 30th 08 08:45 PM
Macro to save file as different filename mac Excel Worksheet Functions 6 November 21st 07 10:43 PM
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
Save as .htm with filename from cell galimi Excel Discussion (Misc queries) 1 May 13th 05 04:51 AM


All times are GMT +1. The time now is 10:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"