VisualBasicHelp
Programmer
Hi,
How can I find the first monday of every month.
With regards
How can I find the first monday of every month.
With regards
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim d As Date
d = DateSerial(Year(Date), Month(Date), 1)
If Date = DateAdd("d", (7 - Weekday(d, 1) + vbMonday) - IIf(Weekday(d, 1) <= vbMonday, 7, 0), d) Then
'run task
End If
[blue]Function DateTest(dt As Date, WeekDayofMonth As Integer, DayofWeek As VbDayOfWeek) As Boolean
DateTest = Weekday(dt) = DayofWeek And (Day(dt) + 6) \ 7 = WeekDayofMonth
End Function[/blue]
[blue]MsgBox DateTest("1 May 2009", 1, vbFriday)[/blue]
[blue]MsgBox DateTest("31 March 2009", 5, vbSaturday)[/blue]
[blue]If DateTest(Now, 1, vbMonday) Then
[green]'do your stuff[/green]
End If[/blue]