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
- 3615 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago