View Single Post
  #5   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

Thanks, Ron and Tom, Ron's approach worked, but Tom's formulae work only with
contiguous ranges (Selection.Rows.Count doesn't return the correct No of
cells in a non-contiguous range).
I thought there is a simpler way than looping through the range one by one.

Regards,
Stefi


€˛Ron Coderre€¯ ezt Ć*rta:

Since you could have more than one area selected,
and the last area selected may be above one of
the other areas...

Try something like this:

Sub LastSelRow()
Dim rArea As Range
Dim iBullpen
Dim iLastSelRow As Single

For Each rArea In Selection.Areas
iBullpen = rArea.Row + rArea.Rows.Count - 1
If iBullpen iLastSelRow Then
iLastSelRow = iBullpen
End If
Next rArea
MsgBox iLastSelRow
End Sub

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"Stefi" wrote in message
...
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