Forum Discussion
DerekHart
Sep 07, 2020Copper Contributor
Is_Date Help!
I want an excel cell to properly detect there is a date in the cell. And then return the date to the cell. I cannot get this reliably working. Sometimes it works, but if I start with a text field in ...
- Sep 09, 2020
Try to do the If in VBA, then forcing the formatting you need
Function IF_IS_DATE(rng As Range) As String If IsDate(rng) = True Then IF_IS_DATE = Format(rng, "Long Date") Else IF_IS_DATE = Application.WorksheetFunction.Trim(rng) End If End Function
Ramiz_Assaf
Sep 09, 2020Iron Contributor
Try to do the If in VBA, then forcing the formatting you need
Function IF_IS_DATE(rng As Range) As String
If IsDate(rng) = True Then
IF_IS_DATE = Format(rng, "Long Date")
Else
IF_IS_DATE = Application.WorksheetFunction.Trim(rng)
End If
End Function
- DerekHartSep 09, 2020Copper Contributor
Ramiz_Assaf This gives me #Name! in the excel field. Can you help?
- Ramiz_AssafSep 09, 2020Iron Contributor
- DerekHartSep 09, 2020Copper Contributor
Ramiz_Assaf super appreciated! Apologies, user error on my part. Working great.