Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Finding a series of values within an Array

I have a two-dimensional array, sorted along one dimension:

e.g.

array(n,1) array(n,2)
10 10020
10 20127
10 30568
11 09654
11 21678
11 54689
12 65894
..
..
99 11111

I want to quickly find only those rows (n) within the array
that match a particular value so that I can limit some looping to only
that area of the array. For instance, let's say I was able to find out
that for the value "11", the lower bound is 4 (if n starts at 1) and
the upper bound is 6.

Any suggestion?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Finding a series of values within an Array

Hi Marston;

My hack is that you could either (1) put the information
into a sheet and then use the pivot table object or (2) it
really seems like a databasing need so put it into Sequel
and then query it if you can. On other option is that you
could write it to a CSV file and then use a dynamic DSN to
execute a sequel statement against it using a text driver.

Others may have better ideas,

Thanks,

Greg
-----Original Message-----
I have a two-dimensional array, sorted along one

dimension:

e.g.

array(n,1) array(n,2)
10 10020
10 20127
10 30568
11 09654
11 21678
11 54689
12 65894
..
..
99 11111

I want to quickly find only those rows (n) within the

array
that match a particular value so that I can limit some

looping to only
that area of the array. For instance, let's say I was

able to find out
that for the value "11", the lower bound is 4 (if n

starts at 1) and
the upper bound is 6.

Any suggestion?

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Finding a series of values within an Array

whatever actually provided that information would need to loop or search.
As far as I know, there is nothing that does, so you need to loop or search
yourself. If you can count on the searched column being sorted, then use a
binary search

check if it is below the lowest value or higher than the upper value, if so
quit.
go to the center of the array,
is it equal to the value: done
is it less than the value
repeat for the lower part of the array
is it greater than the value
repeat for the upper part of the array

now that you have found the value, you can loop down and up to find the
extent of the value


If it is going to be a repetitive process you could preprocess the array to
gather that information in another array.


--
Regards,
Tom Ogilvy

" wrote in message
...
I have a two-dimensional array, sorted along one dimension:

e.g.

array(n,1) array(n,2)
10 10020
10 20127
10 30568
11 09654
11 21678
11 54689
12 65894
.
.
99 11111

I want to quickly find only those rows (n) within the array
that match a particular value so that I can limit some looping to only
that area of the array. For instance, let's say I was able to find out
that for the value "11", the lower bound is 4 (if n starts at 1) and
the upper bound is 6.

Any suggestion?



Reply
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
Finding next number in a series Iriemon Excel Worksheet Functions 2 May 12th 10 09:11 PM
Finding the Max, Min values based on certain criteria for an array swalk88 Excel Discussion (Misc queries) 13 September 10th 09 03:42 AM
Finding Minimum Value in series, excluding zero values [email protected] Excel Worksheet Functions 5 January 30th 07 08:21 PM
Finding series index if I know the Series Name Barb Reinhardt Charts and Charting in Excel 2 January 23rd 07 01:01 PM
Need help finding unique values and transforming an n x 1 Array Marston Excel Programming 3 August 12th 04 07:34 PM


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

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

About Us

"It's about Microsoft Excel"