ApplyFormula Method (WorksheetCell)

Applies a formula to the cell.
Public Sub ApplyFormula( _
   ByVal value As String _
public void ApplyFormula( 
   string value


The formula to parse and apply to the cell.
System.ArgumentNullExceptionvalue is null or empty.
FormulaParseExceptionvalue is not a valid formula.
System.InvalidOperationException The cell is part of an array formula or data table which is not confined to just the cell.

value is parsed based on the CellReferenceMode of the Workbook to which the cell belongs. If the cell's Worksheet has been removed from its parent collection, the A1 CellReferenceMode will be used to parse the formula.

Note: it is slightly faster to use the WorksheetRow.ApplyCellFormula method, which does not create a WorksheetCell instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.ApplyCellFormula method.


Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also