For example, to get the last Thursday of a month, set dow to 5.

Note: I ran into this formula in ananswer on the MrExcel forum by Barry Houdini.

By default, WEEKDAY returns 1 for Sunday and 7 for Saturday, but this is configurable.

Excel formula: Get last working day in month

it’s possible for you to use the WEEKDAY function inside other formulas to check the day of week.

Excel formula: Get nth day of week in month

Excel EOMONTH function

Excel WEEKDAY function