Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Comparing to Arrays

So this is pretty cool - I just found out about the new Google usenet
presentation - things are showing up here much faster than before - no
more 6-10hr turn arounds.

First off, let me say - if my apology to Alan hasn't posted yet -
please read.

Second - let me step back a moment and give some more details:

I have two tasks to complete and the first could utilize the results
from the second, but not necessarily.

Here's the second task:

I have four arrays whose length could very going forward, but in
general, they will have a size similar as follows:

Array1(379,2)
Array2(20009,4)
Array3(262,2)
Array4(1632,2)

As a group, these 4 arrays contain a rule set for the valid combination
of several numbers (although the data is in string format) across 6
items.

What I mean by this is:

Array1(w,1) = Item1
Array1(w,2) = Item2

For any given w, Item1 & Item2 are a valid combination

Array2(x,1) = Item3
Array2(x,2) = Item7
Array2(x,3) = Item1
Array2(x,4) = Item4

For any given x, Item3 & Item 1 & Item4 are a valid combination - and
notice that Item1 is the same as in Array1

Array3(y,1) = Item5
Array3(y,2) = Item6

Array4(z,1) = Item1
Array4(z,2) = Item5

My task is to create a list that aggregates all of the above into a
single array that follows all of the rules from above.

I'd like to end up with the following:

Array5(q,1) = Item1 & Item5 & Item 4 & Item 3 & Item 2 & Item 6
Array5(q,2) = Item7

If it helps, Item1,Item5 and Item6 are always 3 character long; Item2
and Item 4 are always 2 characters long; Item3 is always 5 characters
long; and Item 7 is of variable length.

The routine I've been using is:

Dim Array5(0,2)

count = 0
For h = 1 to Array1length
For i = 1 to Array2length
For j = 1 to Array3length
For k = 1 to Array4length
If Array4(k,2) = Array3(j,1) AND Array4(k,1) = Array2(i,3) AND _
Array4(k,1) = Array1(h,1) Then
count = count +1
ResizeArray Array5,count-1,2
Array5(count-1,1) = Array4(k,1) & Array4(k,2) & Array2(i,4) & _
Array2(i,1) & Array2(i,2) & Array3(j,2)
End If
Next k
Next j
Next i
Next h

Also, if it helps, Array1,2,3&4 are sorted in ascending order by their
first dimension (e.g)

Array1(w,1),Array2(x,1),Array3(y,1)&Array4(z,1)


Looping this way requires it to loop through Array1length x
Arraylength2 x Arraylength3 x Arraylength4 times which is more than 3.2
trillion comparisons. I just figure, there has to be a better way.

For instance, I'd think there has to be someway to take advantage of
the fact that once once the two values being compared in two columns
are such that one set is higher than the first, it will always be so -
since they are sorted. - although that's not necessarily the way I have
it set up because the items being compared are not always the item upon
which the sort was created (it was done externally in a db). I guess I
could sort it on the items being compared because that would probably
help yes/no? But how do I handle the situation with the Array4 where
both its items are being used for comparisons to other arrays -
compare, resort, then compare again?


I'll post the other task in separte post.
Thanks to everyone in advance.

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
comparing ranges/arrays asaylor Excel Worksheet Functions 7 June 13th 06 11:53 PM
Comparing 2 arrays [email protected] Excel Worksheet Functions 3 January 2nd 06 02:31 AM
Comparing Arrays TangentMemory Excel Discussion (Misc queries) 2 May 13th 05 05:06 PM
Comparing Arrays KL Excel Worksheet Functions 9 December 3rd 04 08:58 PM
Comparing to Arrays Marston Excel Programming 7 September 1st 04 01:09 AM


All times are GMT +1. The time now is 06:00 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"