Return last day of a current month
This tutorial shows how to return the last day of a current month using an Excel formula or VBA
Example: Return last day of a current month
=EOMONTH(NOW(),0)
|
This formula uses the Excel EOMONTH and NOW functions to calculate the last day of a current month. Using the NOW function inside the EOMONTH function, with the months criteria of 0, will return the last day in the current month, in date format.
|
Sub Last_Days_of_a_Current_Month()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return the last day in a current month
ws.Range("D5") = Application.WorksheetFunction.EoMonth(Now(), 0)
ws.Range("D5") = Application.WorksheetFunction.EoMonth(Now(), 0)
End Sub
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code.
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code.
EXPLANATION
This tutorial shows how to get the last day of a current month through the use of an Excel formula or VBA.
Both the Excel formula and VBA methods make use of the EOMONTH and NOW functions, with a month criteria of 0, to return the last day of a current month.
FORMULA
=EOMONTH(NOW(),0)
=EOMONTH(NOW(),0)
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Return number of days in a current month | How to return the number of days in a current month using Excel and VBA | |
Return number of days in a month | How to return the number of days in a specific month using Excel and VBA | |
Return previous month based on current month | How to return the previous month based on the current month using Excel and VBA | |
Return next month based on current month | How to return the next month based on the current month using Excel and VBA |
RELATED FUNCTIONS
Related Functions | Description | Related Functions and Description |
---|---|---|
NOW Function | The Excel NOW function returns the current date and time |