How to make number of columns in excel fixed?

the number of columns should be fixed and other than that number the message should written in log file.

thank you.