Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hello,
Is it possible to design a VBA macro that would return the number of days in a specific month? Ex. I'd input a month(December) and the VBA would return (31). Thanks, |
#2
![]() |
|||
|
|||
![]()
The number of days in a month is affected by the year
(leap year), so with a formula use: =EOMONTH((A1&"-"&C1)*1,0)-(A1&"-"&C1)*1+1 where A1 holds the month and C1 holds the year (like 2004). If the formula returns the #NAME? error, install and load the Analysis ToolPak add-in under Tools Add-Ins. HTH Jason Atlanta, GA -----Original Message----- Hello, Is it possible to design a VBA macro that would return the number of days in a specific month? Ex. I'd input a month(December) and the VBA would return (31). Thanks, . |
#3
![]() |
|||
|
|||
![]()
Thank you for help.
Is there a way to get the number of Saturdays and Sundays in specific month ? Ex. I'd input November and Excel would return 8. Regards, "Jason Morin" wrote: The number of days in a month is affected by the year (leap year), so with a formula use: =EOMONTH((A1&"-"&C1)*1,0)-(A1&"-"&C1)*1+1 where A1 holds the month and C1 holds the year (like 2004). If the formula returns the #NAME? error, install and load the Analysis ToolPak add-in under Tools Add-Ins. HTH Jason Atlanta, GA -----Original Message----- Hello, Is it possible to design a VBA macro that would return the number of days in a specific month? Ex. I'd input a month(December) and the VBA would return (31). Thanks, . |
#4
![]() |
|||
|
|||
![]()
Until Jason comes back...
One way with the real date in A1: =DAY(EOMONTH(A1,0))-NETWORKDAYS(EOMONTH(A1,-1),EOMONTH(A1,0)) =DAY(EOMONTH(A1,0)) is another way to get the number of days in a month. =EOMONTH(A1,-1) is the date of the last day of the previous month. =EOMONTH(A1,0) is the date of the last date of the month in A1 =networkdays() is the number of working days (yech!) between two dates. It ignores Saturday and Sunday. If I had "December" in a cell, I'd either type it as a date (12/01/2004, mm/dd/yyyy) and format it to only show the month. Or I'd use a formula like Jason's in a helper cell and use that as the reference in my formula. =(A1&"-"&C1)*1 (format as date and you'll see it) Jeff wrote: Thank you for help. Is there a way to get the number of Saturdays and Sundays in specific month ? Ex. I'd input November and Excel would return 8. Regards, "Jason Morin" wrote: The number of days in a month is affected by the year (leap year), so with a formula use: =EOMONTH((A1&"-"&C1)*1,0)-(A1&"-"&C1)*1+1 where A1 holds the month and C1 holds the year (like 2004). If the formula returns the #NAME? error, install and load the Analysis ToolPak add-in under Tools Add-Ins. HTH Jason Atlanta, GA -----Original Message----- Hello, Is it possible to design a VBA macro that would return the number of days in a specific month? Ex. I'd input a month(December) and the VBA would return (31). Thanks, . -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Ploting dates against a calendar and not as a simple events | Charts and Charting in Excel | |||
Calendar 13 Periods 4 weeks each | Excel Discussion (Misc queries) | |||
Weeks in a Calendar | Excel Discussion (Misc queries) | |||
Fiscal Calendar | Excel Discussion (Misc queries) | |||
calendar spreadsheet | Excel Discussion (Misc queries) |