1. Date VBA function – Description
The Date VBA function returns the current date. If we want Excel VBA to return the current date, we should use this function. The Date function has no arguments. The date value from the Date function is the system date. You can compare the function to the TODAY () formula in an Excel worksheet. If, in turn, we would like VB to return the current date and time or the time itself, we should use the Now () function, which you can read about in this article: VBA Now .
2. VBA Date function – Syntax
Function return: Date / System date.
3. VBA Date function – Example
How to use Date function in VBA Excel? Below is an example of using the Date function in the VisualBasic Editor.
Dim DatExample As Date DatExample = Date MsgBox DatExample
Range ("A1") = Date
4. VB Date function – Additional information
- If we want to enter the date obtained from the Date function into an Excel sheet, we will get a number representing the date in Excel. To avoid this, the date in VBA should be entered into a variable of the string type, or the result of the Date function should be converted using the CStr function .
5. Date VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions.