What are shared formulas? How do I create them?
Excel 2007 has a neat feature which saves a lot of coding when it comes to applying the same formula to a range of cells. A formula in one cell can be marked as
shared and all cells referenced by the shared formula obtain their own version of the formula. So if cell
E5 has the formula
D5*12, then cell
E6 would have the formula
D6*12 etc. etc. To set up a shared formula simply call the CreateSharedFormula method. In the following example, the formula in cell
E5 is marked as
shared and all the other cells in the range
E5:E21 are assigned their own variation of the formula.
worksheet.CreateSharedFormula(worksheet.Cell(5, 5), worksheet.Cell(21, 5));