XLA routines: EE_NthWeekdayOfMonth
EE_NthWeekdayOfMonth returns the nth weekday of the month that a date is in.
- so you could use this function to find the 3rd wednesday in the month (an IMM date for example), or the 2nd Friday... whatever you need
Function EE_NthWeekdayOfMonth(dt As Date, nthWkday As Integer, wkday As EE_Weekday) As Date 'Takes a date, n, and the day of the week (mon, tue, wed) and returns the 2nd tuesday (for example) of the month. Dim x As Integer Dim dtLoop As Date 'http://excelexperts.com/xla-routines-eeNthWeekdayOfMonth for updates on this function For dtLoop = EE_FirstDayOfMonth(dt) To EE_LastDayOfMonth(dt) If Weekday(dtLoop) = wkday Then x = x + 1 If x = nthWkday Then EE_NthWeekdayOfMonth = dtLoop Exit Function End If End If Next dtLoop End Function
»
- Nick's blog
- Login or register to post comments
- 2829 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago