Could you please help me with writing a macro which would generate all the monday's of a month?
Input: Current month For example July 2012
Output: 7/2/2012 7/9/2012 7/16/2012 7/23/2012 7/30/2012
Could you please help me with writing a macro which would generate all the monday's of a month?
Input: Current month For example July 2012
Output: 7/2/2012 7/9/2012 7/16/2012 7/23/2012 7/30/2012
Try this function
This is how you call itPlease Login or Register to view this content.
Please Login or Register to view this content.
Please take time to read the forum rules
The above function generates Tuesdays. The first Tuesday of the wwk is never seen correctly and only from second Tuesday is seen correctly. I made a change and that could get Mondays. Still after a lot of permutations and combinations, the first Monday could not be generated.
Also in the macro Steffen, you can input variables through Excel so that you can have year and month of your choice. It is as follows:
Sub steffen()
Dim mondays
Dim cYear As Long
Dim cMonth As Long
cYear = Application.InputBox(cYear, Type:=1)
cMonth = Application.InputBox(cMonth, Type:=1)
mondays = get_all_mondays(cYear, cMonth)
For i = 1 To UBound(mondays)
Selection.Value = mondays(i)
Selection.Offset(0, 1).Select
Next i
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks