On 12 Apr, 03:55, wrote:
. . . the order of the names in both columns
can be different. Also, the maximum number
of names in each column is 10, but there is
no minimum, therefore the two lists may have
a different number of names. The ultimate
goal of this exercise is to see whether the
names in Column A and B are exactly the same
the order doesn't matter) . . .
You can write various algorithms for this one, but a very easy method
would be to use a simple "stock" algorithm that you probably already
have to hand, a sorting algorithm. Firstly run through the Excel data
and load the names exactly as they appear in the two Excel columns
into two separate
VB String arrays. If the two arrays do not then
contain the same number of strings then straight away you can return a
false, since the list cannot possibly contain exactly the same set of
names. Then, if both arrays do contain the same number of strings,
perform a simple Sort (seperately) on both arrays. The names in the
two arrays will now be in sorted alphabetical order and you can then
simply run through them just once one element at a time conparing
element (n) of the first array with element (n) of the second array.
If you get to the end of the list without finding a "mismatch" on any
element then both arrays are the same. You would probably want to use
a textual comparison, both when yuo perform the sort and when you run
through the elements, so that Bill Gates for example would be seen as
being the same as bill gates.
Mike