View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Tel Tel is offline
external usenet poster
 
Posts: 39
Default rename excel file name

Hi Dave,

Using a code you posted earlier (2004) for which I've marked as "helpful" -
Thanks. I've managed to create the "saveas Macro using cell contents".
However, it automatically saves it to my documents.

Here's my code

Sub save_it()
Dim fname
With ActiveWorkbook
fname = "VMRP_" & .Worksheets("TEST").Range("A1").Value & "_" &
..Worksheets("sheet2").Range("B3").Value & ".xls"
..SaveAs fname
End With
End Sub

Is it possible to insert a break which brings up the saveas dialog box and
enables the user to change the filename (possibly to match their naming
protocols and conventions and pick the location where they would store it?

Many thanks

Terry

"Dave Peterson" wrote:

The only way to rename the file/workbook is to save it with a new name.

Are you sure you want do this?

If so, what folder would you save it to--always the same or pick up the folder
in another cell?

TJ wrote:

Please advise where I would insert this code in the sheet or the workbook.
I am looking for soemthing on the similar lines of sheet i.e.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < Range("a1").Address Then Exit Sub
ActiveSheet.Name = Target

where I am able to change the file name from the sheet itself

thanks
TJ

"Gary''s Student" wrote:

The usual way to rename an excel file from within Excel is to SaveAs the new
name:

Sub Macro2()
Sheets("Sheet1").Activate
ActiveWorkbook.SaveAs Filename:=Range("A1").Value
End Sub

--
Gary''s Student - gsnu200850


"TJ" wrote:

Hi ,

Sorry my question was that I would like to rename the excel file to say
whatever maybe typed in cell A1

regards
TJ


--

Dave Peterson