To check if column header exists and if not then add column with that header

  • I want to write a macro which would check if a data sheet has a set of columns and if not then add a column with that header.

    Say, I want columns Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, col9 to be present and in the same order but the data sheet has missing columns in between so I want the missing column to be created there with the header.

  • Hi,

    Try something along the following lines...

    Note: The code assumes that the column headings are in row 1.

    I have attached an example workbook 'Check and Insert Missing Columns.xlsm' with the above code.


    Tom Rowe...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!