XLL+ Class Library (6.3)

CXlOper::SetFormulaA

Set the formula of the referenced cell, in local format

BOOL SetFormulaA(
   const char* pszFormula,
   BOOL bArray = FALSE,
   BOOL bA1 = TRUE
) const;

Parameters

pszFormula

String buffer containing the formula. The formula is assumed to be in the current language (i.e. in "local" form), using punctuation derived from the user's regional settings, and function names derived from the Excel version.

If the formula is not in the correct format for the current settings, then the call will fail. To use a formula which works under all language settings, see CXlOper::SetFormulaIntl.

bArray

TRUE if the target should be filled with an array formula; FALSE if each cell should be filled with a standard formula.

bA1

If TRUE, then the formula should contain references in A1 format; if FALSE, the references should be in RC format.

Return Value

Returns TRUE if the function was successful, FALSE if it failed. The function can fail if the CXlOper does not contain a reference, if the formula is invalid, or if the function cannot be run in Excel at this time.

Remarks

This function can only be called from macro functions. It will always fail if called from worksheet functions.

International considerations

Be careful when setting formulae that the formula is formatted correctly for the current language settings. For example, arguments in English are separated by commas; in German, semi-colons are used.

You can use CXllApp::GetInternational to get the current list separators and other punctuation characters.

Alternatively, you can use CXlOper::SetFormulaIntl to apply formulae that work in all languages.

Version history

Before XLL+ version 4.3.1, this method contained a bug which caused relative addresses to be wrongly transformed. This has now been fixed.

Requirements

Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlOper::GetFormula() | CXlOper::ConvertFormula() | CXllApp::GetInternational() | CXlOper::SetFormulaIntl()