Last Updated on January 11, 2023 by token
1. Day VBA function – Description
The Day VBA function returns a number that represents the day of the month of a given date. So if we want Excel VBA to return to us numbers corresponding to the next days of the month, we should use this function. It should be remembered that the date from which we want to obtain the number of the day of the month should be taken from the variable or saved in the VB code in the date format, i.e. YYYY-MM-DD .
2. VBA Day function – Syntax
Date : The date from which we want to get the next number corresponding to the day of the month. The date should be in the YYYY-MM-DD format .
Function return: Integer / Numeric value.
3. VBA Day function – Example
How to use the Day function in VBA Excel? Below is an example of using the Day function in the VisualBasic Editor.
Sub DayFunctionExample () MsgBox Day ("2017-12-31") Dim DatDate As Date DatDate = Date MsgBox Day (DatDate) MsgBox Day (Date) Range ("A1") = Day ("2018-05-31") End Sub
4. VB Day function – Additional information
- The date from which we want to obtain the next number of the day of the month should have the Date data type or be saved in the YYYY-MM-DD format.
5. Day VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .