Version

ApplyFormula Method (WorksheetCell)

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

Parameters

value
The formula to parse and apply to the cell.
Exceptions
ExceptionDescription
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.
Remarks

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.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, 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