how to find last row/col index within a selected range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
The application has selected a contiguous range (no empty cell) within a
column (say, from cell B2 to B15). I need to run an analysis on the values
of the selected cells (therefore i'll need loop thru the selected range).
Can someone please tell me how can I locate the upper bound (index) and lower
bound (index) of that range?


Thanks,
Jeff
 
Here's a sample snip that returns the first and last cell of any selected
range

Dim rng As Range
Dim rngLower As Range
Dim rngUpper As Range

Set rng = Selection
Set rngLower = rng.Resize(1, 1)
Set rngUpper = rng.Resize(1, 1).Offset(rng.Rows.Count - 1,
rng.Columns.Count - 1)

MsgBox rngLower.Address
MsgBox rngUpper.Address
 

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

Back
Top