G
Gary''s Student
Is is safe to assume that if the address of a range does not contain a comma,
that it can contain at most one colon??
that it can contain at most one colon??
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
10")Thank you Peter & Chip:
I am trying to help a buddy speed up a very slow macro. Part of her macro
locates the value in the last cell in a range. She does this by looping thru
the range. This MIGHT be necessary if the range is dis-joint.
If, however, the range is not dis-joint (so there are no commas in the
address), then no loop should be needed. She can just SPLIT() the address on
colon and pickup the second element as the address of the terminal item.
4, A1:A2, B6:B10, F1")Gary''s Student said:Thank you Peter & Chip:
I am trying to help a buddy speed up a very slow macro. Part of her macro
locates the value in the last cell in a range. She does this by looping thru
the range. This MIGHT be necessary if the range is dis-joint.
If, however, the range is not dis-joint (so there are no commas in the
address), then no loop should be needed. She can just SPLIT() the address on
colon and pickup the second element as the address of the terminal item.
Thanks again
Ron Rosenfeld said:You could also get the address of the last cell in a contiguous range with :
debug.pring rg(rg.rows.count,rg.columns.count).address
Or, if there are multiple areas:
rg.Areas(rg.areas.count)(...
--ron
Peter T said:Depends what you mean by "last cell". Following returns the last cell of
each area and the bottom right cell which might not exist in any of the
areas at all.
Sub abc()
Dim ra As Range
Dim nR As Long, nC As Long
Set rng = Range("C34, A1:A2, B6:B10, F1")
For Each ra In rng.Areas
With ra
With .Cells(.Count)
If .Row > nR Then nR = .Row
If .Column > nC Then nC = .Column
Debug.Print .Address(0, 0)
End With
End With
Next
Debug.Print "last cell " & Cells(nR, nC).Address ' F10
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.