+ Reply to Thread
Results 1 to 5 of 5

Offset Top Left, Bottom Right backwards?

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Post Offset Top Left, Bottom Right backwards?

    Excel Forum;

    It is my understanding (I am studying a VBA book) that I can set up a range with 2 offset methods, the first selects the top left and the second the bottom right of my desired range. Unfortunately, it seems my understanding of this technique is off. To me, my code appears to select the bottom right first and then the top left of the range. What am I doing wrong?

    My variable nEMP selects my desired range, however, I thought the offset terms would be switched. (I began with .offset(3,1) and .end(xldown) and .end(xltoright) and that didnt work)
    My variable notWorking selects the incorrect range, yet I read it as selecting the headings of the scores. (I would like notWorking to select the nScores range but I want to use the offset method.

    Please Login or Register  to view this content.
    Thank you for your help.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Offset Top Left, Bottom Right backwards?

    Please Login or Register  to view this content.
    You can only OFFset from a reference point(Range). Which Range is your range?
    Please Login or Register  to view this content.
    You are selecting B4, that is going 3 down and 1 to the right, start counting from zero(A1)

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Offset Top Left, Bottom Right backwards?

    Maybe

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    05-19-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Offset Top Left, Bottom Right backwards?

    Quote Originally Posted by Centexcel View Post
    It is my understanding (I am studying a VBA book) that I can set up a range with 2 offset methods, the first selects the top left and the second the bottom right of my desired range. Unfortunately, it seems my understanding of this technique is off. To me, my code appears to select the bottom right first and then the top left of the range. What am I doing wrong?
    The order of the references provided to the Range Property doesn't matter, as you can test with this code...

    Please Login or Register  to view this content.
    The unexpected results you're finding might be due to your understanding how this statement is evaluated...
    Please Login or Register  to view this content.
    It looks like you want to the expression in blue font to return Cell F4.
    However that expression is equivalent to :

    Please Login or Register  to view this content.
    In your example workbook, that expression will return Cell XFD1.
    You can see why this happens by manually selecting A1 then keying Ctrl+Right Arrow

    If you want to get the last non-empty cell in a Row, it's more reliable to use xlToLeft like this..

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Offset Top Left, Bottom Right backwards?

    Wow, this is exactly the response I was looking for.
    Thank you for making this more clear for me!

    I hope once I master VBA I can help others too. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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