Private Function FileDate(inDate As String) As String
' Declarations and Definitions
Dim today As Date
Dim yestDate As String
Dim yestHour As String
Dim yestMinute As String
Dim yestSecond As String
Dim dateLen As Integer
If inDate = "" Then ' If it doesn't already exist, make it
dateLen = 14
today = Now()
yestDate = Format(WorksheetFunction.WorkDay_Intl(today, -1, 1), _
"yyyymmddHhNnSs")
yestDate = Left(yestDate, 8)
yestHour = CStr(Hour(today))
yestMinute = CStr(Minute(today))
yestSecond = CStr(Second(today))
yestDate = yestDate & yestHour & yestMinute & yestSecond
If Len(yestDate) <> dateLen Then ' Account for trimmed '0'
yestDate = yestDate & "0"
End If
FileDate = yestDate ' Return the static date for yesterday
Else
FileDate = inDate ' Return a useable date regardless
End If
End Function