|Since you didn't supply any Row or Column information, the best I can do is offer a generic solution which you can modify to fit your needs.|
For the "function" try something like this:
A B C D
1 YEARS COMPOUND # PERIODS PERIODS
2 5 2 =A2*B2 =IF(ROW()-1<=$C$2,ROW()-1,"")
Drag the formula in D2 down as far as the maximum number of periods you might ever need. In the example above, you should see the numbers 1 - 10 in D2:D11.
For the formatting use Conditional Formatting.
Select the entire table from D2 down as far as it will ever go and out as many columns as it will extend.
1 - Click Conditional Formatting.
2 - Click Manage Rules.
3 - Click the New Rule Box.
4 - Click "Use a formula to determine which cells to format".
5 - Paste this in the "Format values where this formula is true:" field.
6 - Click the Format box and chose a Fill color
7 - Click OK, Click OK and you should get back to the Rules Manager dialog with your Rule displayed.
8 - Repeat steps 3 - 6 but use this Formula as the New Rule:
9 - Click OK, OK, OK and you should be done.
Only the rows with values in Column D will be formatted and the rows will alternate colors based on what color you chose for each Rule.
Basically, what is happening is that the MOD(ROW(), 2) = 0 and MOD(ROW(), 2) = 1 determines if the Row number is Odd or Even, filling the Odd rows with one color and the Even rows with the other.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.