ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to find last row/col index within a selected range (https://www.excelbanter.com/excel-programming/312677-how-find-last-row-col-index-within-selected-range.html)

Jeff

how to find last row/col index within a selected range
 
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

Charles Maxson

how to find last row/col index within a selected range
 
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


--
Charles
www.officezealot.com


"Jeff" wrote in message
...
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




Frank Kabel

how to find last row/col index within a selected range
 
Hi
see:
http://www.xldynamic.com/source/xld.LastValue.html#vba

--
Regards
Frank Kabel
Frankfurt, Germany

"Jeff" schrieb im Newsbeitrag
...
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




All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com