NativeExcel2 for .Net Developer's Reference

IRange.HasFormula Property

Gets a value that indicates whether at least one cell in the range contains a formula.

[Visual Basic]
PropertyReadOnlyHasFormulaAsBoolean
[C#]
boolHasFormula{get;}
[C++]
__propertyboolget_HasFormula();
[JScript]
functiongetHasFormula():bool

Property Value

true if at least one cell in the range contains a formula; otherwise, false.

Example

The following example checks whether the cell A3 contains a formula

[C#]
   IRange cell = book.Worksheets[1].Range["A3"]; 
   if (cell.HasFormula) {
      //do something   
   }      
[VisualBasic]
   Dim cell As IRange
   cell = book.Worksheets(1).Range("A3") 
   If (cell.HasFormula) Then
       'do something
   End If
[C++]
   IRange* cell;
   cell = book->Worksheets->Item[1]->Range->Item[S"A3"];
   if (cell->HasFormula) {
       //do something
   }
The following example checks whether the worksheet one contains a formula
[C#]
   if (book.Worksheets[1].UsedRange.HasFormula) {
      //do something   
   }      
[VisualBasic]
   If (book.Worksheets(1).UsedRange.HasFormula) Then
       'do something
   End If
[C++]
   if (book->Worksheets->Item[1]->UsedRange->HasFormula) {
       //do something
   }

See Also

IRange Interface | NativeExcel Namespace | Formula Property