VBA IsDate Function
In this Article
IsDate Description
Returns True if the expression is a valid date. Otherwise, it returns False.
Simple IsDate Examples
1 2 3 |
Sub IsDate_Example() MsgBox IsDate("4/12/2019") End Sub |
This will return True.
1 |
MsgBox IsDate("4\12\2019") |
Result: False
IsDate Syntax
In the VBA Editor, you can type “IsDate(” to see the syntax for the IsDate Function:
The IsDate function contains an argument:
Expression: An expression that will be evaluated.
Examples of Excel VBA IsDate Function
examples of various valid date:
1 2 3 4 5 6 7 |
MsgBox IsDate("8/22/2019") MsgBox IsDate("8 22 19") MsgBox IsDate("Aug 22 19") MsgBox IsDate("8,22,2019") MsgBox IsDate("8-22-19") MsgBox IsDate("8/22") MsgBox IsDate("8-22") |
Result: True
examples of invalid date:
1 2 3 4 |
MsgBox IsDate("8.22.2019") MsgBox IsDate("8\22\2019") MsgBox IsDate("Aug") MsgBox IsDate("2019") |
Result: False
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!
Learn More!