Dim Myear As Integer
Dim Mmonth As Integer
Dim i As Integer
Dim M As Date
Myear = 2004
Mmonth = 10
M = DateAdd("m", 1, CDate(Myear & "-" & Mmonth & "-01"))
For i = 1 To 3
M = DateAdd("d", -1, M)
If Weekday(M) <> vbSaturday And Weekday(M) <> vbSunday Then
Exit For
End If
Next
MsgBox M