Calculate days in a month

  • Thread starter Thread starter dimpie
  • Start date Start date
D

dimpie

User inputs - Month and year, I need to figure out the last day of the month
for that year (keeping Leap year in mind).

Is there a function in VBA that i can use to get the last day of the
specified mnth and year. If there is not, can you help me figure this out.

Thanks a lot for your help!
 
dimpie said:
User inputs - Month and year, I need to figure out the last day of the
month
for that year (keeping Leap year in mind).

Is there a function in VBA that i can use to get the last day of the
specified mnth and year. If there is not, can you help me figure this out.

Thanks a lot for your help!


The date of the last day of [YearNo], [MonthNo] can be calculated as:

DateSerial([YearNo], [MonthNo] + 1, 0)

The day number, then, is:

Day(DateSerial([YearNo], [MonthNo] + 1, 0))
 
Back
Top