Just a small point on the original version......if you use this formula

=IF($A5="","",IF(MONTH($A5+1)>$A$2,"",$A5+1))

Then when A2=12 that won't prevent the next month showing because 1 < 12

Of course as you know that's only a problem for December you could just keep A36 blank as you won't need that cell for any month......or a subtle change.....

=IF($A5="","",IF(MONTH($A5+1)<>$A$2,"",$A5+1))

You need to use the same sort of change to the weekday formula to make December work, although you could possibly utilise WORKDAY function, e.g. in A6 copied down

=IF($A5="","",IF(MONTH(WORKDAY(A5,1))<>A$2,"",WORKDAY(A5,1)))

WORKDAY is built in in Excel 2007 and later but for earlier versions you need Analysis ToolPak add-in available