Thread: Days in a Month
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zarqy[_2_] Zarqy[_2_] is offline
external usenet poster
 
Posts: 1
Default Days in a Month

for the date in cell b6:

=DAY(DATE(YEAR(B6),MONTH(B6)+1,0))

format for integer


"KyWilde" wrote in message
...
In VBA for excel, how can I find out how many days are in a specific month
for a specific year (these are held in variables)?
For example: I have "curr_month" holding the current month and "curr_year"
holding the current year as well as "last_month", "last_year", etc.
I am trying to get the sum of a category from all the days in a month in a
column, but the months I will want will change and the days in these

months
will change with leap years (februrary), etc. Therefore, instead of
hardcoding all the years this will happen, is there a function in VBA that
does this sort of thing? Thanks!