Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Last Row in Disjoint Range

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Last Row in Disjoint Range

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Last Row in Disjoint Range

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Growth On Disjoint Cells Justin Excel Worksheet Functions 0 May 3rd 07 10:44 AM
COUNTIF with multiple disjoint ranges, same criteria Ron Coderre New Users to Excel 5 March 4th 06 08:11 AM
COUNTIF with multiple disjoint ranges, same criteria Bob Phillips New Users to Excel 1 March 3rd 06 11:02 PM
COUNTIF with multiple disjoint ranges, same criteria CLR New Users to Excel 0 March 3rd 06 08:00 PM
Disjoint range for DSUM criteria Jim Bennett Excel Worksheet Functions 2 June 9th 05 03:50 AM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"