View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default last row of a non-contiguous selection

Hi Ron,

Thank you for your reply! The problem is that my request was
misunderstandable. I didn't mean that the entire column is selected, but all
selected cells are in the same column, e.g. A3,A5,A8, etc. The only solution
up to now is Ron Coderre's approach.

Regards,
Stefi


€˛Ron Rosenfeld€¯ ezt Ć*rta:

On Fri, 28 Mar 2008 06:38:00 -0700, Stefi
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