+ Reply to Thread
Results 1 to 5 of 5

Compare 2 arrays using Match

  1. #1
    Registered User
    Join Date
    09-27-2010
    Location
    Adelaide
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Compare 2 arrays using Match

    Hi All,
    I have two arrays which I want to compare, using Match.
    The code below is what i have so far, but it is failing on the Redim Preserve ArrNot(k) line, with error "Run-time error '13' Type Mismatch"
    All arrays are defined as Variant.
    Just not sure how to proceed with debugging.

    Cheers,
    Skimmer333


    Please Login or Register  to view this content.
    Last edited by skimmer333; 10-06-2010 at 08:25 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Compare 2 arrays using Match

    Hi skimmer333
    declare
    Please Login or Register  to view this content.
    but what are you doing there has to be a better way than rely on errors?

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Compare 2 arrays using Match

    this would be better
    Please Login or Register  to view this content.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Compare 2 arrays using Match

    Like Pike says without knowing what you're trying to do nor how the initial arrays are being created it's hard to give specific advice.

    By the looks of it something like:

    Please Login or Register  to view this content.
    might work for you... obviously the code for creation of Arr, ArrResults is not there as we don't know how you're creating them.

    In the above I sized ArrNot to be the same as Arr initially (max no. of possible values) and ReDim'd on completion based on k with Preserve (best to do as infrequently as possible)

    Then posted the results of ArrNot to J1:Jn where n determined by size of ArrNot
    (you might need to clear pre-existing results beforehand... again not clear if required or not)
    Last edited by DonkeyOte; 10-07-2010 at 03:28 AM. Reason: missing k & l declaration

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Compare 2 arrays using Match

    Example:

    Please Login or Register  to view this content.
    The string c01 contains all values in array sn that array sq doesn't.

    But in this case you don't even need to compare arrays:

    Please Login or Register  to view this content.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1