ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to create Automatic Filenames in Excel (https://www.excelbanter.com/excel-discussion-misc-queries/56958-how-create-automatic-filenames-excel.html)

Trevor6410

How to create Automatic Filenames in Excel
 
I am trying to work out how to get Excel to automatically create the File
Name when the Workbook is saved. I want a filename to be create using the
contents of a given Cell + the current date/time... Ideally, I want a Macro
attached to the sheet which Saves the document.

Dave Peterson

How to create Automatic Filenames in Excel
 
Option Explicit
Sub testme03()

Dim myFileName As String

myFileName = ThisWorkbook.Worksheets("Sheet99").Range("a99").Va lue _
& "--" & Format(Now, "yyyy_mm_dd__hh_mm_ss") & ".xls"

ThisWorkbook.SaveAs Filename:=myFileName
End Sub

Not much testing--no folder included (unless it's in that cell).


Trevor6410 wrote:

I am trying to work out how to get Excel to automatically create the File
Name when the Workbook is saved. I want a filename to be create using the
contents of a given Cell + the current date/time... Ideally, I want a Macro
attached to the sheet which Saves the document.


--

Dave Peterson


All times are GMT +1. The time now is 02:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com