Macros and Programming in XCEL

New Contributor


I would like to create a macro in XCEL which populates column headers and formulas based upon a number loaded into cell.  Example:  Cell G3 - 5 gets typed into the cell (number of years).  Result - 5 columns appear in the xcel spreadsheet with header and formula.  I have tried using the "if" formula in the columns to say if it's above 1 populate, if it's above 2 the next populates, etc...  Didn't work.  Not sure how to accomplish this but I am quite sure the program can.  Thank you!



3 Replies


Where should the columns appear?

What should the headers contain?

In which rows do you want formulas?

What should the formulas look like?

The column headers are Year 1, Year 2, Year 3, etc... - depending upon the number placed in the cell representing Number of Years. The formulas would be in the rows directly below the Year 1...


Thanks. What formulas do you need?