JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
Finding that M$FT in its infinite wisdom chose not to provide a built-in IsDate function to go along with all of the other IsXxx functions, I decided to write my own. Here it is:
It works fine if I pass it a cell address or the scalar name of a cell, but not if I pass it a named range of the column the cell is in.
[TABLE="class: grid, width: 450"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]TRUE[/TD]
[TD]D4: =myisdate(C4)[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]TRUE[/TD]
[TD]D5: =myisdate(temp)[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D6: =myisdate(DateUseBy)[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D7: =myisdate(+DateUseBy)[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D8: =myisdate(0+DateUseBy)[/TD]
[/TR]
</tbody>[/TABLE]
Column C is named "DateUseBy".
Cell C5 is named "temp".
If I put stop on the UDF, the parameter "cell" shows up as "empty" in the last three calls (D6-D8).
What do I have to do to get Excel to pass the cell contents to the UDF for these calls?
Code:
Function MyIsDate(ByVal cell As Variant) As Boolean
MyIsDate = IsDate(cell)
End Function
It works fine if I pass it a cell address or the scalar name of a cell, but not if I pass it a named range of the column the cell is in.
[TABLE="class: grid, width: 450"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]TRUE[/TD]
[TD]D4: =myisdate(C4)[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]TRUE[/TD]
[TD]D5: =myisdate(temp)[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D6: =myisdate(DateUseBy)[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D7: =myisdate(+DateUseBy)[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]11/12/19[/TD]
[TD="align: center"]FALSE[/TD]
[TD]D8: =myisdate(0+DateUseBy)[/TD]
[/TR]
</tbody>[/TABLE]
Column C is named "DateUseBy".
Cell C5 is named "temp".
If I put stop on the UDF, the parameter "cell" shows up as "empty" in the last three calls (D6-D8).
What do I have to do to get Excel to pass the cell contents to the UDF for these calls?