### Hacking the Hack

If you plan to use the top-level formula more than once—for
instance, to evaluate each holding in your portfolio—you
won't want to name dozens of cells or create
separate formulas for each application of the formula. Not only does
it take too much time, it's mind-numbingly tedious
as well. However, after you get your calculations working properly,
it's easy to go back and paste the intermediate
calculations into the top-level formula. You can then copy the
complete formula to other cells. To incorporate subroutine
calculations into a top-level formula, start at the top and work your
way down, replacing cell references with the contents of the cell, as
shown here.

The original top-level formula is:

=IF(ISNUMBER(Investment),test_diversification,"Investment isn't a number.")

You can replace the named cell references with the formulas in those
cells or, for references to values, the cell address, as shown in the
following steps:

=IF(ISNUMBER(C2),IF(InvestPercent> 0.25,"Check diversification",
"Leave it alone"),"Investment isn't a number.")

At this point, you can repeat Steps 1 through 4 to replace the cell
reference `InvestPercent` with the formula in that
cell. Then, repeat Steps 1 through 4 until you either replace all
cell references with their corresponding calculations or run out of
nesting levels. If you replace every intermediate calculation, the
diversification formula looks like the one in .