View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.newusers
taylorm
 
Posts: n/a
Default Excell Macro Help Please


This macro assumes that the date you want appended to the file name
exists in a named range (DateRange) on Sheet1.

If the original filename was -Book1.xls -and the DateRange had 1/25/06,
the resulting filename would be -Book1_01-25-2006.xls-


Sub AppendDateToFilename()

Dim strDate As String
Dim strFullName As String

'Saves the file in the same directory with the text (date) from Sheet
"Sheet1" Rangename "DateRange" appended to the original filename
strDate = Format(Worksheets("Sheet1").Range("DateRange"),
"mm-dd-yyyy")
strFullName = Left(ActiveWorkbook.FullName,
Len(ActiveWorkbook.FullName) - 4) & "_" & strDate & ".xls"
ActiveWorkbook.SaveAs Filename:=strFullName _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub


Hope this is what you needed!


--
taylorm
------------------------------------------------------------------------
taylorm's Profile: http://www.excelforum.com/member.php...o&userid=28892
View this thread: http://www.excelforum.com/showthread...hreadid=505054