H33=IF($J31="Weekly",$R31-MOD(WEEKDAY($R31)+1,7)+(COLUMNS($H31:H31)-1)*7,EOMONTH($R31,COLUMNS($H31:H31)-1)-MOD(WEEKDAY(EOMONTH($R31,COLUMNS($H31:H31)-1))+1,7))

Try in H33 and copy towards right
i found some wrong references in your present formula in H33