Dave Patton
Well-known Member
- Joined
- Feb 15, 2002
- Messages
- 6,345
- Office Version
- 365
- 2010
- Platform
- Windows
I have a UDF "AGE" that requires a test to ensure dates are in the SS for d1 and d2.
If a person enters an invalid date such
as Feb 30, it shows as Text on the ss but function defaults to Dec 31 1899.
Probably solution could put text such as
"Input error, Invalid Date" instead of incorrect date for result.
I tried
if application.worksheetfunction.istext(d1)
But I did not get it to work
Function Age(d1 As Date, d2 As Date, Optional Output As Variant = "T")
.... ...
.... output
Select Case UCase(Output)
Case "D": Age = d
Case "H": Age = Array(Y, M, d)
Case "M": Age = M
Case "V": Age = Application.WorksheetFunction.Transpose(Array(Y, M, d))
Case "Y": Age = Y
Case Else: Age = Y & "y " & M & "m " & d & "d"
End Select
End Function
Thanks for your help
If a person enters an invalid date such
as Feb 30, it shows as Text on the ss but function defaults to Dec 31 1899.
Probably solution could put text such as
"Input error, Invalid Date" instead of incorrect date for result.
I tried
if application.worksheetfunction.istext(d1)
But I did not get it to work
Function Age(d1 As Date, d2 As Date, Optional Output As Variant = "T")
.... ...
.... output
Select Case UCase(Output)
Case "D": Age = d
Case "H": Age = Array(Y, M, d)
Case "M": Age = M
Case "V": Age = Application.WorksheetFunction.Transpose(Array(Y, M, d))
Case "Y": Age = Y
Case Else: Age = Y & "y " & M & "m " & d & "d"
End Select
End Function
Thanks for your help