hgus393
Registered User.
- Local time
- Today, 07:27
- Joined
- Jan 27, 2009
- Messages
- 83
Hi all,
I am trying to write some code to populate a table with the nearest 65 working days from a starting point. However since the code ignores Saturdays and Sundays it does not populate the table with 65 days only with 65 days -(minus) Saturdays and Sundays... Does anyone know how to get around that?
Cheers Rob
I am trying to write some code to populate a table with the nearest 65 working days from a starting point. However since the code ignores Saturdays and Sundays it does not populate the table with 65 days only with 65 days -(minus) Saturdays and Sundays... Does anyone know how to get around that?
Cheers Rob
Code:
Sub Workdays()
Dim dtDate As Date
Dim i As Integer
Dim rs As Recordset
Dim r As Integer
Dim Newdate As Date
dtDate = InputBox("Import Date: (YYYY-MM-DD):", "Hold on...!")
Set rs = CurrentDb.OpenRecordset("Buckets")
r = 65
For i = 1 To r
Select Case (Weekday(dtDate + i))
Case Is = vbSunday
Case Is = vbSaturday
Case Else
Newdate = DateAdd("d", i, dtDate)
rs.AddNew
rs!Bucket = Newdate
rs.Update
End Select
Next i
End Sub