Last cell within an address

R

raj

Hello,

Does anyone know the easiest way (i.e. most
efficient/fewest code lines/fastest code, etc.) to select
the S.E. corner or bottom right cell address from a single
area range address stored in a variable?

For example, if my variable contains: strRange = "$2:$4"
My function would return the string: "$IV$4"

OR,

If my variable contains: strRange = "$BA457:FJ1057"
My function would return the string: "$FJ$1057"

Your example code would be most appreciated. Thanks much
for your assistance.
 
C

Charles Maxson

Raj,

Here ya go!


Using a range parameter (better):

Function LastCellFromRange(rng As Range)
LastCellFromRange = rng.Resize(1, 1).Offset(rng.Rows.Count - 1,
rng.Columns.Count - 1).Address
End Function

Using a string parameter:

Function LastCellFromString(sRng As String)
LastCellFromString = Range(sRng).Resize(1,
1).Offset(Range(sRng).Rows.Count - 1, Range(sRng).Columns.Count - 1).Address
End Function
 

Ask a Question

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.

Ask a Question

Top