application.match and multidimensional array?

K

KR

I need to find out if certain values are in one part of a multidimensional
array. In the past I've used application.match against 1-dimensional arrays
to see if it throws an error (which tells me it isn't in the array).
Unfortunately I can't find any help for match or application.match in the
VBE help. Using XL2003 on Win2000.

Can I do the same thing with a multidimensional array, and if so, what is
the proper way to identify the array in the match? e.g. should I just have
the array name
(MySource())
or do I need to specify the part of the array to search
(MySource(1,))

Or do I have to copy the part of the array where I want to check for matches
to a new 1-D array? That would be inefficient, since I'll be looping and
adding hundreds (maybe thousands) of entries...but I have to find the
matches (or lack thereof), so I'm open to options.

I'd prefer not to deal with collections if there is a way to keep all this
in my array.

Thanks!
Keith
 
B

Bernie Deitrick

Keith,

Are you using data in cells as your array, or are you working on an array in code?

In either case, you could use the Find method on a range (paste the range to a temp range if you are
using an array).

HTH,
Bernie
MS Excel MVP
 
K

KR

I'm using several arrays in code (memory); the smaller array keeps a subset
of values that I'm tracking, and with each iteration of my code, it checks
that subset against the larger set to grab additional values. The larger
array is approximately (1 to 10, 1 to 5000) and the smaller array can be
anywhere from (1 to 10, 1 to 100) up to (1 to 10, 1 to 5000) where the
latter would end up including every element from the source array.

In my case, I'm going through up to 10 iterations where in each case I'm
checking for a cascade of values in the source array (thus my iterations);
for example, lets assume that it is a list of 5000 people who all know at
least some of the other people on the list. I might decide that I want to
know who I listed as my friends, in which case I'll only check to see who I
had listed as friends. Or I might want to know 1 degree of separation, in
which case I'll iterate through my own friends to generate a new source
list, then using that, I'll check for every unique value of any name that me
and my immediate friends have listed as friends...and so on...

I can iterate through my source array just fine, what I'm trying to do is
determine if each name that is found is unique to my sublist array so that I
can add it (and related information) if needed.

My alternative is to keep a single-dimension array just for the match
criteria, and add each new record to both that and my multidimensional
sublist at the same time. My concern about using the sheets is just speed
more than anything else- but perhaps I should go test it to see if it really
slows down the code that much...

Thanks!
Keith
 

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

Top