+ Reply to Thread
Results 1 to 10 of 10

2 Arrays with same elements but sequence different

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    2 Arrays with same elements but sequence different

    HI

    Ar1=array("Muhammad","Imran","Bhatti")
    Ar2=array("Bhatti","Imran","Muhammad")


    Same elements but sequence is different

    I want them to be the same ..How?

    All elements of Ar1 also exist in Ar2 (no matter with different sequence) So a boolean Are2ArraysEqual should be true

    Thoughts?

    Thanks in Advance.
    Teach me Excel VBA

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: 2 Arrays with same elements but sequence different

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: 2 Arrays with same elements but sequence different

    Thanks sir jindon I can't challenge the solution but its me not understanding, how can I adjust my Are2ArraysEqual = True ?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: 2 Arrays with same elements but sequence different

    All elements of Ar1 also exist in Ar2 (no matter with different sequence)
    If conditions are given, it always True.

    Am I missing something?

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: 2 Arrays with same elements but sequence different

    lemme rephrase the question

    Please Login or Register  to view this content.
    In case of current example: All element of Ar1 also exist in Ar2

    So the boolean should return true.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: 2 Arrays with same elements but sequence different

    Something like this.
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: 2 Arrays with same elements but sequence different

    I think its near to what is required

    Now the problem is that of sequence i.e if the sequence of Ar1 goes here

    Please Login or Register  to view this content.
    Then it should also return "True" because all elements of Ar1 exist in Ar2 with different sequence.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: 2 Arrays with same elements but sequence different

    Try changing this line
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: 2 Arrays with same elements but sequence different

    OOps, other way around
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: 2 Arrays with same elements but sequence different

    Yes that did the trick.
    Question in thread title is solved. I am going to post another post as I want it to make further flexible.

    This thread is solved

    Thank you so much @sir jindon and also Yasser (to point out a correction in jindon's solutions)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] sumproduct only uses first elements in arrays
    By maxwell888 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-08-2016, 01:07 PM
  2. Comparing arrays and deleting elements
    By consumer48 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2015, 07:31 PM
  3. Comparing Elements in Multiple Arrays
    By gibbsa08 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2014, 06:50 AM
  4. Arrays elements is not returns the values to Calling function
    By amarendra19 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2011, 12:44 AM
  5. Reorder elements a cell using arrays, split & join
    By k8_dog in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-12-2011, 01:58 PM
  6. Accessing elements within arrays
    By JP789 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-17-2009, 08:47 AM
  7. [SOLVED] Elements and Arrays in Excel
    By Lighthouseman in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-01-2006, 06:10 AM

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