XLL+ Class Library (7.0)


Creates a reference from an address

BOOL MakeRef(
   const TCHAR* pszAddress,
   BOOL bA1 = TRUE,
   BOOL bLocal = FALSE



The address of a cell or range of cells.

This can include a worksheet name, in "[book]sheet" format. If the worksheet name is omitted, the address will be assumed to be in the worksheet of the cell from which the current add-in function was called.

The following addresses are all valid:


The following address is valid in English only:


The address can also contain a named range.


TRUE if the address is in A1 format; FALSE if the address is in R1C1 format.


If bLocal is TRUE then the reference will always be external, i.e. it will include a sheet ID and IsMRef() will return TRUE. If bLocal is FALSE then the reference will only be external if it refers to a sheet other than the current sheet. If it refers to the current sheet, then it will not include a sheet ID and IsSRef() will return TRUE.

Return Value

Returns TRUE if the function was successful, FALSE if it failed. The function can fail if the address string is not valid for any reason.


This function will create a reference from a string address. The reference can then be used to access the contents of the cell, for example with the methods SetValue() and Coerce(). The function will fail if the address is not found.

International considerations

Be aware when creating a reference using this method that the address should be formatted for the current language settings. This has no impact on "A1" style adresses, but "RC" style addresses use different letters in different Excel language versions. For example, "R1C1" in English is "Z1S1" in German.

You can use CXllApp::GetInternational(XlInternationalUpperCaseRowLetter) and CXllApp::GetInternational(XlInternationalUpperCaseColumnLetter) to get the current letters.

Alternatively, you can use CXlOper::MakeRefIntl to create addresses that work in all Excel language versions.

See Using references and Setting formulae in the User Guide for more information.


CXlOper::Coerce() Example


Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlOper::MakeRefIntl() | CXlOper::FromMRef() | CXlOper::FromSRef() | CXllApp::MakeSheetName()