Gets or sets the formula for the NamedRange control, using A1-style references in the language of the user.
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Using this property on a NamedRange control that contains multiple cells will cause an exception to be thrown.
If the cell contains a constant, this property returns that constant. If the cell is empty, this property returns an empty string. If the cell contains a formula, this property returns the formula as a string, in the same format in which it would be displayed in the formula bar (including the equal sign).
If you set the value or formula of a cell to a date, Microsoft Office Excel checks to see whether that cell is already formatted with one of the date or time number formats. If not, the number format is changed to the default short date number format.
If the range is a one-dimensional or two-dimensional range, you can set the formula to an array of the same dimensions. Similarly, you can put the formula into an array.
The following code example creates a NamedRange and then uses the property to set the value of the NamedRange to equal the sum of the values of cells A1 and A2. The formula is localized according to the language of the system it is run on.
This example is for a document-level customization.