DateValue Function: Return a Variable Containing a Date Value | Excel Help
Your Programming and Traning Professionals

DateValue Function: Return a Variable Containing a Date Value


Excel DateValue Function

DateValue Function is used to return a variant variable, which contains a date value.

The Basics:

DateValue(Date)

Now let’s look at an example. Let’s assume that I have a string value on an Excel worksheet which I want to convert to a date variable.

Code

Dim ValueToProcess As Variant’Variable to hold the string to be processed

ValueToProcess = DateValue(ActiveSheet.Cells(1, 1).Value)

ActiveSheet.Cells(3, 1).Value = ValueToProcess

Output

Note:

So why do we need this Excel function? The Excel DateValue is a great function to automatically convert a string for assignment to a date variable when you need it.