Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
I found this function that calculates the week of a month and it works great on a spreadsheet but I need to work on a userform.
The date will be coming from the DTPicker1 value and the WeekOfMonth will be displayed inside lblWotM.caption on the UserForm1.
Thanks
Code:
Function WeekOfMonth(dDate1 As Date) As String Dim dDate2 As String
Dim wWeek As Integer
'dDate2 is changed to date from String
dDate2 = VBA.CDate(Month(dDate1) & "/01/" & Year(dDate1))
wWeek = DateDiff("ww", dDate2, dDate1.Value, vbSunday, vbUseSystem) + 1
'Return the Week number of the month
'Monday is taken as week starting date, you can change
'it to your desired day as starting date of week
WeekOfMonth = wWeek
End Function
Thanks