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
- 3603 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago