ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Array compare (https://www.excelbanter.com/excel-programming/311710-help-array-compare.html)

GMet

Help with Array compare
 
I have 2 arrays from which I want to create a 3d. I need to compare the
TotArray with the UsedArray and put the difference into AvailableArray. For
example

TotArray
Ford
Chevy
Datsun
Nisan
Toyota

UsedArray
Ford
Chevy
Datsun

AvailableArray
Nisan
Toyota

I can't seem to get the



No Name

Help with Array compare
 
This might work..

dim x as integer
dim Add as boolean
dim availarray(1)
x = 1
for i = 1 to ubound(totarray)
add = true
for j = 1 to ubound(usedarray)
if totarray(i) = usedarray(j) then
Add = false
next j
if add = true then
redim availarray(x)
availarray(x) = totarray(i)
x = x + 1
end if
next i


-----Original Message-----
I have 2 arrays from which I want to create a 3d. I need

to compare the
TotArray with the UsedArray and put the difference into

AvailableArray. For
example

TotArray
Ford
Chevy
Datsun
Nisan
Toyota

UsedArray
Ford
Chevy
Datsun

AvailableArray
Nisan
Toyota

I can't seem to get the


.


pikus

Help with Array compare
 

Will UsedArray always be the same up to a point as TotArray? As in, wil
the difference always be because one is longer than the other?

Do you only want to compare the items with the same index number or d
you want to know if the value is matched anywhere at all in the othe
array?

Are the arrays organized in some useful way?

Is it possiblethat you would have dupliate entries in one array and i
so, assuming the value is found only once in the other array, shoul
the value be added to your new array?

Would I be correct in assuming that the UsedArray only contains value
from the TotArray?

Thanks - piku

--
piku

I have two kids. :-
-----------------------------------------------------------------------
pikus's Profile: http://www.excelforum.com/member.php...nfo&userid=355
View this thread: http://www.excelforum.com/showthread.php?threadid=26422


GMet

Help with Array compare
 
The UsedArray is always a subset of the TotArray
The difference between TotArray and UsedArray will always go into AvailArray
There are never duplicates in any of the arrays
The TotArray is organized by number in ascending order
( the original example shows cars, but the actual data is a text field
of numbers) - never more than 8
TotArray
411310
411320
411330
411340
411350
411360

The items in the UsedArray may not be contiguous - for example
UsedArray
411320
411340
411360

GMet

"pikus" wrote in message
...

Will UsedArray always be the same up to a point as TotArray? As in, will
the difference always be because one is longer than the other?

Do you only want to compare the items with the same index number or do
you want to know if the value is matched anywhere at all in the other
array?

Are the arrays organized in some useful way?

Is it possiblethat you would have dupliate entries in one array and if
so, assuming the value is found only once in the other array, should
the value be added to your new array?

Would I be correct in assuming that the UsedArray only contains values
from the TotArray?

Thanks - pikus


--
pikus

I have two kids. :-)
------------------------------------------------------------------------
pikus's Profile:

http://www.excelforum.com/member.php...fo&userid=3550
View this thread: http://www.excelforum.com/showthread...hreadid=264223





All times are GMT +1. The time now is 05:29 PM.

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