LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Fastest way to find item in an array.

I have an array of 40 items.
I need to go down a column of 600 cells and for each cell I need to
test whether the cell.value is equel to any of the items in the array.
At present this is really slow as my code is doing a loop of 40, 600
times (i.e 24,000).
The loop looks something like:

For i= 1 to 600
myVal = cells(i,1)
For j = 1 to 40
if myVal = myArray(j) then blah blah
next j
next i

Would I have been better using a collection rather than an array?
Is an array the best choice?

Any help greatly appreciated,
J

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
'auto find average of 4 fastest times' Ditchy Excel Discussion (Misc queries) 3 February 12th 10 10:01 PM
To find rate of each item from item.xls and to copy price.xls pol Excel Discussion (Misc queries) 7 July 16th 09 12:49 AM
fastest sorting routine for 2-D array of long values RB Smissaert Excel Programming 8 May 6th 06 05:06 PM
does an item belong to an array? wcc Excel Programming 4 October 21st 04 08:46 AM
Find fastest way to do lookups Fred Smith Excel Programming 7 April 18th 04 07:44 AM


All times are GMT +1. The time now is 08:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"