Understanding Range.Cells(x,y)

1. Understanding Range.Cells(x,y)

How do you explain these?

Range("D10")(0, 0).Select 'Selects C9
How do you move left and up when you have 0? Why not move right and down or right and up?

Range("D10")(-1, -1).Select 'Selects B8

I don't understand how these cells are counted either. It's as if you have to add an addition 1, actually -1, to each value to derive the answer.

Please explain how these work.

2. Re: Understanding Range.Cells(x,y)

Hi,

Range("D10")(1,1) would give you the cell that resides in the first row and first column of the range "D10".

So therefore Range("D10")(0,0) offsets "D10" by -1 row and -1 column (C9 in this case), and a similar argument for B8.

In a general sense, the (x,y) coordinates are relative to the "first" (upper-left most) cell in the specified range, and the "first" cell is represented by (1,1). So (x,y) would specify the row that is x - 1 rows below the row of the "first" cell in the specified range, and the column that is y - 1 columns to the right.

I hope this has cleared things up a little bit for you

3. Re: Understanding Range.Cells(x,y)

Using Offset might make things a bit simpler, and easier to understand.
``Please Login or Register  to view this content.``

4. Re: Understanding Range.Cells(x,y)

@Norie: agreed *thumbs up*!

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1