Excel's Range Object

J

Jerry West

I'm attempting to get a relative Range like so:

Set xlWrkBook = Excel.Application.Workbooks.Open(sPath$)

Set xlWrkSht = Excel.Application.ActiveSheet

Set xlRng = xlWrkSht.Range("A1")
Set xlRngNew = xlRng.Range("A1")

I would expect that xlRng.Range("A1") would return a reference to the cell
"B1" but it is still "A1".

Can some tell me what I am doing wrong here.

Any insight would be greatly appreciated!!

JW
 
P

Patrick Smith [MSFT]

You are setting a relative reference of a root from the root. This is
correctly returned as A1 if the root of your range is A1.

If you set xlRng to C3, then setting xlRngNEW = xlRng.Range("a1") would be
C3...if it weren't, how would you ever get to the top left cell in your
range?

In other words, the relative range of A1 should be the top left cell in your
range object. In the example you give, that is what is happening.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top