EVALUATE

This function uses the Microsoft Excel parser and function evaluator to evaluate any expression that could be entered in a worksheet cell.

Returns the result of evaluating the string.

Syntax

Excel4(xlfEvaluate, LPXLOPER pxRes, 1, LPXLOPER pxFormulaText)

pxFormulaText (xltypeStr)

The string to evaluate, optionally beginning with an equal sign (=).

Remarks

Limitations

The string can contain only functions, not command equivalents. It is equivalent to pressing F9 from the formula bar.

Primary Use

The primary use of the EVALUATE function is to allow DLLs to find out the value assigned to a defined name on a sheet.

External References

EVALUATE cannot be used to evaluate references to an external sheet that is not open.

Macro Example

The following example takes a text value, a5, and jumps to the location it represents by using the EVALUATE function.

Example

This example uses xlfEvaluate to coerce the text "B38" to the contents of cell B38.

\SAMPLES\EXAMPLE\EXAMPLE.C

short int WINAPI EvaluateExample(void)
{
    XLOPER xFormulaText, xRes, xRes2, xInt;

    xFormulaText.xltype = xltypeStr;
    xFormulaText.val.str = "\004!B38";
    Excel4(xlfEvaluate, (LPXLOPER)&xRes, 1, (LPXLOPER)&xFormulaText);

    xInt.xltype = xltypeInt;
    xInt.val.w = 2;
    Excel4(xlcAlert, (LPXLOPER)&xRes2, 2, (LPXLOPER)&xRes, 
        (LPXLOPER)&xInt);
    Excel4(xlFree, 0, 1, (LPXLOPER)&xRes);
    Excel4(xlFree, 0, 1, (LPXLOPER)&xRes2);

    return 1;
}