Address Property Read Only String

Tea237 ly®

The Address property returns the range reference of the Range object as a string. The syntax is:

RangeObject.Address(RowAbsolute, ColumnAbsolute, ReferenceStyle, External, RelativeTo)

RowAbsolute is set to True (the default) to return the row part of the reference as an absolute reference. ColumnAbsolute is set to True (the default) to return the column part of the reference as an absolute reference.

ReferenceStyle can be one of the XlReferenceStyle constants xlA1 or xlR1C1. The default value is xlA1.

Set the External parameter to True to return an external reference—that is, a reference that is qualified by the workbook and worksheet names and is thus valid outside the current worksheet. The default value of False returns a reference that is not qualified and is therefore valid only within the current worksheet.

Finally, the RelativeTo parameter is used when RowAbsolute and ColumnAbsolute are False and ReferenceStyle is xlR1C1. In this case, we must include a reference point (a cell) to use for the relative addresses. Let us consider some examples to help clarify this property:

rng.Address(ReferenceStyle:=xlA1)

rng.Address(ReferenceStyle:=xlA1,

External:=True) [Book1]Sheet1!$B$2

rng.Address(ReferenceStyle:=xlR1C1) rng.Address(RowAbsolute:=False,

ColumnAbsolute:=False, ReferenceStyle: rng.Address(RowAbsolute:=False,

ColumnAbsolute:=False, ReferenceStyle: RelativeTo:=Range("D1"))

Set rng = Range("B2:D5") rng.Address(ReferenceStyle:=xlA1) rng.Address(ReferenceStyle:=xlR1C1) rng.Address(RowAbsolute:=False,

ColumnAbsolute:=False, ReferenceStyle: rng.Address(RowAbsolute:=False,

ColumnAbsolute:=False, ReferenceStyle: RelativeTo:=Range("D1")) 2]:R[4]C

' Returns R2C2

' Returns R2C2:R5C4

=xlR1C1,

0 0

Post a comment