Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Title pretty much says it all. How do I find the last row in a disjoint range assuming they're all in the same object? ie. What do I put in here? Function GetLastRow (Target as Range) as Long 'Target range is not contiguous GetLastRow = ? End Function Thanks, Scott |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hmmm, maybe answered my own question. Would appreciate verification
that nothing bad can happen with this (ie. can you end up with the last item not being in the last row)? GetLastRow = Target(Target.Count).Row Thanks, Scott Scott wrote: Hi, Title pretty much says it all. How do I find the last row in a disjoint range assuming they're all in the same object? ie. What do I put in here? Function GetLastRow (Target as Range) as Long 'Target range is not contiguous GetLastRow = ? End Function Thanks, Scott |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Scott,
Try it and it won't work on multiple areas. The only way I can get it to work is as follows: Sub SubGetLastRow() MsgBox CStr(GetLastRow(Selection)) End Sub Function GetLastRow(Target As Range) As String 'Target range is not contiguous Dim rCell As Range Dim lRow As Long For Each rCell In Target If rCell.Row lRow Then lRow = rCell.Row Next rCell GetLastRow = lRow End Function It's not very effecient but it works. -- Hope this helps Martin Fishlock, Bangkok, Thailand Please do not forget to rate this reply. "Scott" wrote: Hmmm, maybe answered my own question. Would appreciate verification that nothing bad can happen with this (ie. can you end up with the last item not being in the last row)? GetLastRow = Target(Target.Count).Row Thanks, Scott Scott wrote: Hi, Title pretty much says it all. How do I find the last row in a disjoint range assuming they're all in the same object? ie. What do I put in here? Function GetLastRow (Target as Range) as Long 'Target range is not contiguous GetLastRow = ? End Function Thanks, Scott |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Growth On Disjoint Cells | Excel Worksheet Functions | |||
COUNTIF with multiple disjoint ranges, same criteria | New Users to Excel | |||
COUNTIF with multiple disjoint ranges, same criteria | New Users to Excel | |||
COUNTIF with multiple disjoint ranges, same criteria | New Users to Excel | |||
Disjoint range for DSUM criteria | Excel Worksheet Functions |