ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Named Range or through cells (https://www.excelbanter.com/excel-programming/425601-named-range-through-cells.html)

Alan[_8_]

Named Range or through cells
 
In general, is it faster to go through each cell in a column when
looking for a particular value, or faster to reference a named range
for the area to search?

Thanks, Alan



Jim Cone[_2_]

Named Range or through cells
 
1. It is usually much faster to use the "Find" method.
2. Special cells can help narrow the search.
3. Not accessing the worksheet cells directly but referencing a Range Object
or loading the cell values into a Variant and then looping thru
one or the other is the next choice...

Set rngCol = Range("A10:A1000")
For Each rCell in rngCol
-or-
varRng = Range("A10:A1000").Value
For N = LBound(varRng, 1) To UBound(varRng, 1)
--
Jim Cone
Portland, Oregon USA



"Alan"
wrote in message
In general, is it faster to go through each cell in a column when
looking for a particular value, or faster to reference a named range
for the area to search?
Thanks, Alan



JBeaucaire[_90_]

Named Range or through cells
 
Both are equally fast in properly designed code. The named range approach
means you use less code to restrict the search range, but ultimately it
should execute with equal precision.

--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"Alan" wrote:

In general, is it faster to go through each cell in a column when
looking for a particular value, or faster to reference a named range
for the area to search?

Thanks, Alan





All times are GMT +1. The time now is 07:01 AM.

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