Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Mar 2006
    Location
    Princeton, New Jersey, USA
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding last row of a selection (Excel 2000 or 2003)

    Hi ... so glad this site is back up! ...

    I have a macro that can get the first row of a selection of rows with this:
    FirstRow = Selection.Rows

    Now I need to know the EndRow of this selection. (Sorry, I'm working on a PC that did not install the Help ... )

    EndRow=Selection.???

    As always, I appreciate any help at all.
    --cat

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    EndRow = selection.row + selection.rows.count-1

    Steve

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    I'm not sure what you are after. Selection.Rows returns a range object that includes all of the rows in the current selection. If you really meant Selection.Row, then that would return the row number of the first row in the first area in the current selection.

    Are you looking for the row number of the last row in the current selection? If so, then what do you want if the current selection contains more than one area?
    Legare Coleman

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    Steve: That is not going to work if the selection contains more than one area.
    Legare Coleman

  5. #5
    Star Lounger
    Join Date
    Mar 2006
    Location
    Princeton, New Jersey, USA
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    Thanks, Steve. That works. But even better, the Selection.Rows.Count is actually what I'm after (i was going to calculate it by EndRow-StartRow)!
    Thank you,
    --cat

  6. #6
    Star Lounger
    Join Date
    Mar 2006
    Location
    Princeton, New Jersey, USA
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    Sorry, Legare ... I forgot to add that the users will be trained to select entire rows (and the rows will always be contiguous). What I actually needed was a row count of this row selection.

    Thank you both for your help ...
    --Cindy

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Finding last row of a selection (Excel 2000 or 2003)

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15> You are, of course, correct. I presumed the selection was contiguous.

    Steve

Posting Permissions

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