+ Reply to Thread
Results 1 to 8 of 8

Help matching rows

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    Lo
    MS-Off Ver
    Excel 2016
    Posts
    4

    Help matching rows

    Hi,

    I need help matching the X (column A) and Y (column B) variables in the attached file with INDEX(MATCH) but I'm failing at the MATCH part.

    The situation:
    Both, X and Y can be numbers or numbers mixed with text. The Y variables always have 6 digits but the first digit might be a leading 0. The Y variables should represent the first 6 digits of the X variables, but the X variables should not have the leading 0.

    The approach:
    After removing the leading 0 from the Y variable (column C) I tried the following:

    1) comparing Y with the left part of X, which is dependent on the length of Y
    = Match (Y; Left (X; Length (Y);0)

    2) I wasn't sure MATCH would work with LENGTH and LEFT, so I tried shortening X to the length of Y first (column G and H) and then match column B with G and H.
    G = Left (X; 6)
    H = Left (X; 5)
    = Match (Y; G; 0)
    = Match (Y; H; 0)

    3) instead of of comapring X and Y with the same number of digits, I tried comparing Y* with X
    = Match (Y & "*"; X;0)

    None of my ideas work properly. I'm not sure why - might be due to formatting but I haven't been able to solve it that way. Any ideas?

    Thank you.
    Attached Files Attached Files
    Last edited by Iwantto; 12-07-2018 at 05:03 AM.

  2. #2
    Registered User
    Join Date
    02-03-2012
    Location
    Lo
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Help matching rows

    no longer important
    Last edited by Iwantto; 12-07-2018 at 05:06 AM.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 2000/3/7/10/13/16
    Posts
    45,691

    Re: Help matching rows

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

    STOP PRESS: Forum Rules Updated September 2018! Please read them here.

  4. #4
    Registered User
    Join Date
    02-03-2012
    Location
    Lo
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Help matching rows

    Thanks. It's uploaoded now. I always pressed Attachements in the Text Editor and a small, blank window popped up. Pressing Manage Attachements further down below worked.

  5. #5
    Forum Guru Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    19,825

    Re: Help matching rows

    Maybe this in D2, copied down:

    =IF(B2="","",IFERROR(1/(1/SUMPRODUCT(--ISNUMBER(SEARCH(IFERROR(B2+0,B2),$A$2:$A$300)),ROW($A$2:$A$300))),""))
    Attached Files Attached Files
    Glenn



  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    4,754

    Re: Help matching rows

    Try in E2:
    Please Login or Register  to view this content.
    Drag down

  7. #7
    Registered User
    Join Date
    02-03-2012
    Location
    Lo
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Help matching rows

    Thank you. Both solutions seem to be working. Solution 1 should also work with several leading zeroes.

    bebo021999: Can you explain what the index function does in =index(1 ; )=1? What does the empty argument represent?

    Can someone tell me why my match function didn't work? Below is an abbreviated version: seaching for 459200 in column A. When I format column A as a number, text or general, then MATCH shows me an error (see top half). But when I add +0 to column A, the match function works fine (see bottom half). What's the difference between formatting a cell as a number and adding +0?

    458683 459200 =MATCH($B$1;$A$1:$A$2;0) = #NA
    459200

    =A1+0 459200 =MATCH($B$4;$A$4:$A$5;0) = 2
    =A2+0

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    4,754

    Re: Help matching rows

    Quote Originally Posted by Iwantto View Post
    bebo021999: Can you explain what the index function does in =index(1 ; )=1? What does the empty argument represent?
    Please Login or Register  to view this content.
    Let's say:
    X=IF(LEFT(B2)="0",MID(B2,2,255),B2) will change 012345 into 12345, or 456789 into itself
    SEARCH(X,$A$2:$A$300) will search X string in A2, A3, ...then A300
    for instant: X=1234; A3=123456
    SEARCH(X,A3)=1 (X string is found at 1st position in A3)
    so, SEARCH(X,$A$2:$A$300) establish (0,1,0,0,...,0), (let's say: Y)
    then, MATCH(1,Y,0) will return pos of 1 in Y array
    This is array formula, confirmed by ctrl-shift-enter (CSE)
    To avoid CSE, wrap Y inside INDEX function:
    =MATCH(1,INDEX(Y,),0)
    This is my final formula

    Hope it helps

+ 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