Home |
Search |
Today's Posts |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Day of the month
I usually do it something like this (VBA might not be exactly right):
Sub test() Dim i As Integer ' i = Last_Day_of_Month(2, 2009) ' Last day of Feb, 2009? MsgBox "Last day of Feb, 2009 = " & i ' End Sub Function Last_Day_of_Month(theMonth As Integer, theYear As Integer) As Integer Dim date1 As Date, date2 As Date ' date1 = DateSerial(theYear, theMonth, 1) ' First day of input month/year date2 = DateAdd("m", 1, date1) ' Add a month to get first day of next month Last_Day_of_Month = Day(DateAdd("d", -1, date2)) ' Then subtract one day to get last day of input month/year ' End Function ' HTH, Eric |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel to make the days cary over month to month automaticly | New Users to Excel | |||
Excel 2003 month to month data change grid | Excel Discussion (Misc queries) | |||
Retrieve data for previous 3, 6, 12 month given current month | Excel Worksheet Functions | |||
copy worksheet from previous month and rename to current month | Excel Programming | |||
transfer cell $ amount to other sheet month-to-month without overc | Excel Discussion (Misc queries) |