+ Reply to Thread
Results 1 to 4 of 4

Understanding Range.Cells(x,y)

  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    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. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    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. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    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.
    Last edited by Norie; 08-21-2013 at 10:55 PM.
    If posting code please use code tags, see here.

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Understanding Range.Cells(x,y)

    @Norie: agreed *thumbs up*!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Understanding why some cells work and some don't with formula
    By coronas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-23-2013, 01:02 PM
  2. Need help understanding this code. Upload range from excel to sql.
    By Weibull in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2012, 06:24 PM
  3. Replies: 2
    Last Post: 06-24-2010, 11:44 PM
  4. understanding code .cells().resize() ect.
    By caliskier in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2007, 12:25 PM
  5. [SOLVED] Understanding Range Names and Labels
    By Robert_Steel@nospam.com in forum Excel General
    Replies: 4
    Last Post: 06-02-2005, 01:05 PM

Tags for this Thread

Bookmarks

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