Evaluate Method

       

Evaluates an expression that is in the form of text and returns the result. The expression can include any combination of functions, keywords, or other syntax that the Spreadsheet Component can resolve.

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:

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