Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 4 May 2007 11:12:35 -0700, DF wrote:
Does someone know off hand a function that would count the number of individual days in a given month? For example, how many Mondays in May 2007, how many Tuesdays, etc... I've searched the help files and did not find anything I could use. Thanks in advance for your help. --DFruge =4+(DAY(A1-DAY(A1)+1-WEEKDAY(A1-DAY(A1+DOW))+35)7) Where DOW is the Day Of the Week with Monday = 1 Tuesday = 2 etc. Or, in VBA, something like: ======================================== Option Explicit Sub WDinMonth() Dim DOW As Long Dim Dt As Date Dt = DateValue(InputBox("Enter Month and Year")) Debug.Print "Number of Weekdays in " & Format(Dt, "mmm yyyy") For DOW = 1 To 7 Debug.Print _ Application.WorksheetFunction.Choose(DOW, _ "Monday", "Tuesday", "Wednesday", "Thursday", _ "Friday", "Saturday", "Sunday"), _ 5 + (Day(Dt - Day(Dt) + 1 - Weekday(Dt - Day(Dt + DOW)) + 35) < 7) Next DOW End Sub ==================================== Note that in VBA the comparison in the formula is reversed because, in VBA, TRUE = -1 and FALSE = 0 --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel to make the days cary over month to month automaticly | New Users to Excel | |||
Number of days in month counted from shortened name of month & yea | Excel Worksheet Functions | |||
CountDays? need to count days in range by month | Excel Worksheet Functions | |||
User defined function to count pay days in current month. | Excel Programming | |||
Count number of days in given month? | Excel Worksheet Functions |