Re: last row of a non-contiguous selection

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Fri, 28 Mar 2008 06:38:00 -0700, Stefi <Stefi@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

Hi All,

I have a one column wide non-contiguous selection. I want to determine the
row No of the last cell in the selection (the highest row No in the
selection).
How can I do that?

Thanks,
Stefi

You do write that you have the entire column selected.

In that case:

=============
Option Explicit
Sub lastrow()
Dim c As Range
Dim lLastRow As Long
Set c = Cells(Selection.Rows.Count, Selection.Column)
Set c = c.End(xlUp)
lLastRow = c.Row

Debug.Print lLastRow

End Sub
======================

or

=====================
Sub lastrow()
Dim lLastRow As Long

lLastRow = Cells(Selection.Rows.Count, Selection.Column).End(xlUp).Row

Debug.Print lLastRow
End Sub
===============
--ron
.



Relevant Pages

  • Re: last row of a non-contiguous selection
    ... selected cells are in the same column, e.g. A3,A5,A8, etc. ... I have a one column wide non-contiguous selection. ... Dim lLastRow As Long ...
    (microsoft.public.excel.programming)
  • Re: last row of a non-contiguous selection
    ... (there's no email, no snail mail, but somewhere should be gmail in my addy) ... I have a one column wide non-contiguous selection. ... row No of the last cell in the selection (the highest row No in the ...
    (microsoft.public.excel.programming)
  • RE: last row of a non-contiguous selection
    ... If your selection includes the last entry in the column, ... (change "A" to the correct column). ... which will work whether your selection includes ... row No of the last cell in the selection (the highest row No in the ...
    (microsoft.public.excel.programming)
  • last row of a non-contiguous selection
    ... I have a one column wide non-contiguous selection. ... row No of the last cell in the selection (the highest row No in the ...
    (microsoft.public.excel.programming)
  • Re: last row of a non-contiguous selection
    ... Sorry Bob, it doesn't do what I mean! ... I have a one column wide non-contiguous selection. ... row No of the last cell in the selection (the highest row No in the ...
    (microsoft.public.excel.programming)