Evaluate Method

Microsoft Office Web Components Visual Basic

expression.Evaluate(Expression)

expression    Required. An expression that returns one of the objects in the Applies To list.

Expression   Required Variant. The expression to evaluate.

Remarks

The following types of names in Microsoft Excel can be used with this method:

  • A1-style references. You can use any reference to a single cell in A1-style notation. All references are considered to be absolute references.
  • Ranges. You can use the range, intersect, and union operators (colon, space, and comma, respectively) with references.
  • Defined names. You can specify any name in the language of the macro.

Example

This example uses the the Evaluate method to calculate the cotangent of an angle.

Function CalcCotangent(sngAngleInDegrees)

    Dim strExpression

    ' Put together the expression to calculate the cotangent
    ' of the angle.
    strExpression = "1/TAN(" & sngAngleInDegrees & "*PI()/180)"

    ' Evaluate the string and return the result.
    CalcCotangent = Spreadsheet1.ActiveSheet.Evaluate(strExpression)

End Function