ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Number of Specific Day within Dates (https://www.excelbanter.com/excel-worksheet-functions/235454-re-number-specific-day-within-dates.html)

Alan McQ via OfficeKB.com

Number of Specific Day within Dates
 
Hi Abdul,

You can use the below function to count the days. First though, you will need
to copy the code at the end of this post into a VBA module.

A1 B1 C1 D1
1 Jun 2009 30 Jun 2009 Thursday =countday(A1,B1,C1)


Public Function CountDay(StartDate As Date, EndDate As Date, DayName As
String) As Long
Dim iDate As Date, dCount As Long

iDate = StartDate
dCount = 0

Do Until iDate EndDate
If Not iDate EndDate Then
If Format(iDate, "dddd") = DayName Then
dCount = dCount + 1
End If
End If
iDate = iDate + 1
Loop

CountDay = dCount

End Function

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200906/1



All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com