Excel: Using R1C1 Notation When Using A1 NotationLast reviewed: November 2, 1994Article ID: Q45248 |
SUMMARYWhen testing cell contents from a macro in Microsoft Excel, R1C1 style text references must be converted from text if the environment is set to A1 notation (that is, R1C1 is not selected in Options Workspace). In most cases, Excel treats R1C1 references as pure text if the environment is set to A1 notation, resulting in erroneous or misleading comparisons.
MORE INFORMATIONExamples of these erroneous or misleading comparisons are shown in the following examples:
=ISBLANK("R[1]C1") always returns FALSE because the text string
"R[1]C" is not an empty text string.
=IF("R1C1"=1,TRUE,FALSE) always returns FALSE, even if A1
contains the number "1" because the number 1 is not equal to the
text string "R1C1".
=MID("R1C1",1,2) always returns "R1", regardless of the text that
may be contained in cell A1 because "R1" is the first two characters
of the text string "R1C1".
These situations can be avoided by converting the text into references
with the TEXTREF function. The statement TEXTREF("R[1]C1",FALSE)
returns the reference R[1]C1, which can then be used to find the
contents of that cell. As a result, the correct syntax for the above
examples becomes the following:
=ISBLANK(TEXTREF("R[1]C1",FALSE))
=IF(TEXTREF("R1C1",FALSE)=1,TRUE,FALSE)
=MID(TEXTREF("R1C1",FALSE),1,2)
Note that there are a few functions, such as the SELECT statement,
that do correctly treat text-style R1C1 references as references.
These functions do not accept text arguments, so there is no ambiguity
as to whether you intend them to be used as text or as a reference.
|
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |