+ Reply to Thread
Results 1 to 16 of 16

matching numbers with different digits orders

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2005
    Posts
    16

    matching numbers with different digits orders

    hi, i have part numbers which are 3 digits numbers and 4 digits numbers, they may have leading zeros too.

    let's try the 3-digit numbers first (if it works, it should work for 4-digits numbers)

    column A listing the part numbers
    column B is another set of numbers i need to match
    column C is the value to display on column D if A&B "matches"
    column D is the result (taken from column C)

    A & B "matches" if B has all the numbers in A, but not necessarily in the same order.

    for example:

    A B C D
    123 213 tokyo tokyo (A & B matches)
    123 124 osaka #n/a (doesn't match)
    055 505 osaka osaka (A & B matches)
    5566 6556 kyoto kyoto (A & B matches)


    MATCH function won't work i guess.

    i've tried "disecting" column A into 3 separate columns listing a single digit
    =LEFT(A1,1) returns 1
    =MID(A1,2,1) returns the second digit 2
    =RIGHT(A1,1) returns 3

    then i tried using combination of IF, AND, OR fucntions to try make it work. and it's a mess

    suggestions welcome.
    thanks,

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try...

    D1, copied down:

    =IF(SUMPRODUCT(--ISNUMBER(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),B1)))=LEN(B1),C1,#N/A)

    Hope this helps!
    Last edited by Domenic; 05-10-2005 at 10:30 PM.

  3. #3
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Correction...

    =IF((SUMPRODUCT(--ISNUMBER(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),B1)))=LEN(B1))*(LEN(A1)=LEN(B1)),C1,#N/A)

    Hope this helps!

    Quote Originally Posted by Domenic
    Try...

    D1, copied down:

    =IF(SUMPRODUCT(--ISNUMBER(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),B1)))=LEN(B1),C1,#N/A)

    Hope this helps!

  4. #4
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    this is a mess, but here goes

    part numbers in cells a3 and b3

    d3 =VALUE(LEFT(A3,1))
    e3 =VALUE(MID(A3,2,1))
    f3 =VALUE(RIGHT(A3,1))
    g3 =VALUE(LEFT(B3,1))
    h3 =VALUE(MID(B3,2,1))
    i3 =VALUE(RIGHT(B3,1))
    j3 =IF(AND(LARGE(D3:F3,1)=LARGE(G3:I3,1),LARGE(D3:F3,2)=LARGE(G3:I3,2),LARGE(D3:F3,3)=LARGE(G3:I3,3)),"good","bad")

    bascally this forces a comparison of the descending order of the digits of the part number

    just a shot at it
    not a professional, just trying to assist.....

  5. #5
    Registered User
    Join Date
    05-10-2005
    Posts
    16
    oh my..u guys sure are fast

    Domenic,
    the formula will return
    0021 and 0321 as "matched" or
    1200 and 2110 as "matched" too

    (EDIT: your correction formula same results)

    btw, i have to format column A & B as TEXT because of leading zeros.


    duane,
    i'm looking thru your method,

    thanks

  6. #6
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Quote Originally Posted by foxxkat
    Domenic,
    the formula will return
    0021 and 0321 as "matched" or
    1200 and 2110 as "matched" too

    (EDIT: your correction formula same results)
    Yep, I just checked it and you're right. Even with my corrected formula it returns the wrong results. I have to get going, but I'll give it some more thought tomorrow.

    Cheers!

  7. #7
    Registered User
    Join Date
    05-10-2005
    Posts
    16
    hi again, sorry to miss out one important point:
    part numbers to be matched to the range of numbers in column B

    \1


    Explanations:

    i named the range B2:B11 = MASTER3

    D3 returns a result of "Tokyo" because:
    A3 "matches" to B4 (regardless of the digits orders), then take C4 value which is "Tokyo"

    another example:
    D8 returns result of "200" because:
    A8 "matches" to B6 (regardless of the digits orders), then take C6 value which is "200"

    another example:
    D11 returns "no match" because:
    A11 has no match in any of the numbers (regardless of the digits orders) in MASTER3 (B2:B11)

    and the most complicated example:
    D10 returns "525 & Tokyo" because:
    A10 "matches" to B3 (regardless of the digits orders), then take C3 value which is "525"
    and also
    "matches" to B8 (regardless of the digits orders), then take C8 value which is "Tokyo"



    column A & B are formatted as TEXT because may have leading zeros.
    A & B also has fixed number of digits, 4 (including leading zeros if any).

    my list runs to the hundreds

    your help/suggestions greatly appreciated.

    thanks,
    Last edited by foxxkat; 05-11-2005 at 01:23 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    given that i think a vba solution is in order. Read in all the part #'s in column b into an array:

    colb(1,1) = 1st entry, max digit
    colb(1,2) = 1st entry, next highest digit
    .....
    colb(2,1) = 2nd entry, max digit
    ......

    then go down column a parts and start a comparison of the max digit, next highest, etc and if a match is found make appropriate entry in column d (copy column c)

+ 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