Attendance Sheet - extra column appearing

How to avoid an extra column from appearing
for e.g. my have created attendance sheet using 31 days month
but when i change month and use either Feb or 30 days month
extra column appears and have to be hidden manually.
is there any method ( formula ) which will only generate columns as per selected month without having to manually hide / unhide