Here is an example which you will need to alter slightly so that monday is first day of week. Also to use danish day names.
The function below can be used to determine how many days (e.g Mondays etc) there are in any specified month. For example
=HowManyDaysInMonth("1/12/03","wed")
Will return 5 as there are five Wednesdays in the month of December in 2003
=HowManyDaysInMonth("1/12/03","thu")
Will return 4 as there are four Thursdays in the month of December in 2003
To be able to use this custom function in a Workbook, you must first place the code below into a standard module.
Open the Workbook. Go to Tools>Macro>Visual Basic Editor (Alt+F11). Then to Insert>Module. Paste in the code. Click the top right X to return to Excel. 'The Code
Function HowManyDaysInMonth(FullDate As String, sDay As String) As Integer Dim i As Integer Dim iDay As Integer, iMatchDay As Integer Dim iDaysInMonth As Integer Dim FullDateNew As Date
iMatchDay = Weekday(FullDate) Select Case UCase(sDay) Case "SUN" iDay = 1 Case "MON" iDay = 2 Case "TUE" iDay = 3 Case "WED" iDay = 4 Case "THU" iDay = 5 Case "FRI" iDay = 6 Case "SAT" iDay = 7 End Select iDaysInMonth = Day(DateAdd("d", -1, DateSerial _ (Year(FullDate), Month(FullDate) + 1, 1))) FullDateNew = DateSerial(Year(FullDate), Month(FullDate), iDaysInMonth) For i = iDaysInMonth - 1 To 0 Step -1 If Weekday(FullDateNew - i) = iDay Then HowManyDaysInMonth = HowManyDaysInMonth + 1 End If Next i End Function
Great, you need to accept my answer to close the question :o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.