Looking for a line of code or formula to check if two strings have the same characters but not necessarily in the same order (without using a loop or sorting the strings)
e.g.
ABCDE
BEADC
should result in a match
Thanks
Looking for a line of code or formula to check if two strings have the same characters but not necessarily in the same order (without using a loop or sorting the strings)
e.g.
ABCDE
BEADC
should result in a match
Thanks
Hi
Assumes that your data is in A1:A2, and you only have 5 characters in the string. If you have a variable number, then let us know.
=AND(ISNUMBER(SEARCH(MID(A1,ROW(A1:A5),1),A2))) (array entered).
HTH
rylo
Thanks rylo.
Works only if the two strings are the same length and no repeats. For example comparing AAAAA with ABCDE return true!
Also not sure about the extra functions and the array formula, but shouldn't this simplified version work just as well for any number of characters?
=ISNUMBER(SEARCH(MID(A1,1,1),A2))
Thanks
Last edited by matrex; 10-12-2012 at 12:32 PM.
Hi
So there are a few more things to consider.
1) if the strings are not the same length, then is that an automatic fail?
2) if there are repeats is that an automatic fail?
3) is this a one way compare, or both way (ie are you comparing all the items in A1 with A2, or does A2 also have to work with A1)
are there any more things to consider?
rylo
rylo
It should be a 100% identical match (character for character) except that the characters do not have to be in the same order. So yes the length of the string should be the same
Also the characters could be numeric
ABCDE & BDCAE ==> YES
AACDE & BDCAE ==> NO
1234 & 3412 ==> YES
Thanks
Still waiting for a solution....
Hi
This does seem to be extremely cumbersome, but I think it does get you there. Array entered of course.
ryloPlease Login or Register to view this content.
Works great as long as the strings are in column A. Wonder if it could be adapted to work on any cells
Thanks for your continued assistance
Last edited by matrex; 10-16-2012 at 05:37 PM. Reason: Solved
Hi
Of course, just put in the relevant cell references as required.
rylo
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks