Personally i would get rid of the Merged cells, nothing good will ever come from merged cells - they are a terrible idea.
Anyway rant over, in the first box (a1) i would put
Code:
=IF(EOMONTH($D$6,-1)+COLUMNS($J$4:J4)>EOMONTH($D$6,0),"",TEXT(EOMONTH($D$6,-1)+COLUMNS($J$4:J4),"DD"))
and in the one above
Code:
=IF(EOMONTH($D$6,-1)+COLUMNS($J$4:J4)>EOMONTH($D$6,0),"",TEXT(EOMONTH($D$6,-1)+COLUMNS($J$4:J4),"DDD"))
and incredment each number accross (which is horrible with merged cells - the Columns part deals with this but wont work with merged cells)
Its a bit more complex but far more robust - see my example on your control sheet