View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claud Balls Claud Balls is offline
external usenet poster
 
Posts: 72
Default counting Sundays between two dates

Option Explicit
Sub date_count()
Dim StartDate As Date, EndDate As Date, CurrentDate As Date
Dim DaySum As Integer
Dim Holidays As String
DaySum = 0
Holidays = Range("C1") & Range("C2") & Range("C3") & Range("C4") &
Range("C5")
StartDate = Range("A1")
EndDate = Range("A2")
For CurrentDate = StartDate To EndDate Step 1
If InStr(1, Holidays, CurrentDate, vbTextCompare) = 0 Then
If Weekday(CurrentDate) < 1 Then
DaySum = DaySum + 1
End If
End If
Next
MsgBox DaySum
End Sub

When you paste this in, account for the syntex being jacked up because
of the width limit of this window.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!