XLA routines: EE_DateFileName
EE_DateFileName if a function that creates a date / time stamped file name in yyyymmdd format so that it can be sorted in Explorer
Function EE_DateFileName(strFileName As String, Optional varFileDate As Variant, Optional blnAddTime As Boolean) As String '- takes a file name ' 'Optional: ' FileDate As Variant ' AddTime As Boolean ' '- if date is missing, it appends today's date formatted as: '_yyyymmdd' '- if AddTime is true, add 'hhmmss' of Now() ' '- returns file name with appended date stamping Dim strNewFileName As String 'http://excelexperts.com/xla-routines-eeDateFileName for updates on this function strNewFileName = strFileName If IsMissing(varFileDate) Or IsEmpty(varFileDate) Then strNewFileName = strNewFileName & "_" & Format(Date, "yyyymmdd") Else strNewFileName = strNewFileName & "_" & Format(CDate(varFileDate), "yyyymmdd") End If If blnAddTime Then strNewFileName = strNewFileName & "_" & Format(Now(), "hhmmss") End If EE_DateFileName = strNewFileName End Function
»
- Nick's blog
- Login or register to post comments
- 3640 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago