K
kvdwerf
Excel 2000 problem:
When putting in a cell a formula referring to a custom VBA function,
that returns a date or variant/date, the result is formatted as a
number.
When putting in a cell a std function like =TODAY(), the result is
formatted as a date.
Questions: does this problem occur in higher versions of Excel as well,
and is there maybe some way around?
I already tried to return a Variant/String containing the preformatted
date, but Excel does not recognize result as a date
'Results in the number "37987" appearing in the cell
Public Function TestDateFormat1() As Date
TestDateFormat1 = Date 'Returns the current system date
End Function
'Results in the number "37987" appearing in the cell
Public Function TestDateFormat2() As Variant
TestDateFormat2 = Date
End Function 'Results in 37987 in the cell
'Results in a left aligned string "2004/01/01" in the cell
Public Function TestDateFormat3() As Variant
TestDateFormat3 = Format(Date, "yyyy/mm/dd")
End Function
Many thanks
When putting in a cell a formula referring to a custom VBA function,
that returns a date or variant/date, the result is formatted as a
number.
When putting in a cell a std function like =TODAY(), the result is
formatted as a date.
Questions: does this problem occur in higher versions of Excel as well,
and is there maybe some way around?
I already tried to return a Variant/String containing the preformatted
date, but Excel does not recognize result as a date
'Results in the number "37987" appearing in the cell
Public Function TestDateFormat1() As Date
TestDateFormat1 = Date 'Returns the current system date
End Function
'Results in the number "37987" appearing in the cell
Public Function TestDateFormat2() As Variant
TestDateFormat2 = Date
End Function 'Results in 37987 in the cell
'Results in a left aligned string "2004/01/01" in the cell
Public Function TestDateFormat3() As Variant
TestDateFormat3 = Format(Date, "yyyy/mm/dd")
End Function
Many thanks