+ Reply to Thread
Results 1 to 7 of 7

how to select the last two row

  1. #1
    Registered User
    Join Date
    05-03-2010
    Location
    quincy
    MS-Off Ver
    Excel 2003
    Posts
    21

    how to select the last two row

    Hi,

    I know use Range("w65536").End(xlUp).Select to direct last row, but how to get last two row value?

    Thanks
    Last edited by poppypoppy; 06-09-2010 at 10:38 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: how to select the last two row

    Maybe:

    Please Login or Register  to view this content.

    Not sure what you are doing but it's worth noting it's almost never necessary to use Select in VBA code.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to select the last two row

    Domski is right. IF you look at the next thing you were going to do after selecting, that line of code was probably going to start with Selection..... so you can usually just merge all those lines together at the Select/Selection overlap.

    Please Login or Register  to view this content.

    In your code, if the next thing you were going to is copy the entire row, take off the select and immediately copy the entire row:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    05-03-2010
    Location
    quincy
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: how to select the last two row

    Excellent. It works. Thanks


    Quote Originally Posted by Domski View Post
    Maybe:

    Please Login or Register  to view this content.

    Not sure what you are doing but it's worth noting it's almost never necessary to use Select in VBA code.

    Dom

  5. #5
    Registered User
    Join Date
    05-03-2010
    Location
    quincy
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: how to select the last two row

    Thank you so much


    Quote Originally Posted by JBeaucaire View Post
    Domski is right. IF you look at the next thing you were going to do after selecting, that line of code was probably going to start with Selection..... so you can usually just merge all those lines together at the Select/Selection overlap.

    Please Login or Register  to view this content.

    In your code, if the next thing you were going to is copy the entire row, take off the select and immediately copy the entire row:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to select the last two row

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    05-03-2010
    Location
    quincy
    MS-Off Ver
    Excel 2003
    Posts
    21

    Smile Re: how to select the last two row

    just did thanks

    Quote Originally Posted by JBeaucaire View Post
    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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