plaidshirt
plaidshirt

Reputation: 5671

Range object's Range object

How should we interpretate the following?

Range("A2:A3").Range("E2:E3").Select

I can't imagine, how comes the result of above code. I have tried to test it on several times, but I can't.

Upvotes: 0

Views: 44

Answers (1)

cronos2546
cronos2546

Reputation: 1106

It is a relative reference. In this case, you would select E3:E4 because Excel would assume that your active range starts at A2 (ie A2 = A1).

See https://msdn.microsoft.com/EN-US/library/office/ff834676.aspx

When applied to a Range object, the property is relative to the Range object. For example, if the selection is cell C3, then Selection.Range("B1") returns cell D3 because it’s relative to the Range object returned by the Selection property. On the other hand, the code ActiveSheet.Range("B1") always returns cell B1.

Upvotes: 2

Related Questions