+ Reply to Thread
Results 1 to 7 of 7

Find the last-row result of multiple matches?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-08-2011
    Location
    China
    MS-Off Ver
    Excel 2003
    Posts
    6

    Find the last-row result of multiple matches?

    Now I've tried a couple of methods but none yeiled desirable result so far.

    I want to search "Jay Abrams" from sheet1, file A in colum F of sheet1,file B, now, there are more than 1 match in colum F sheet1,file B. I want the result at the last position, or in other words, data with the max row number.

    I've tried lookup, but the resulf wasn't correct.

    Now I'm using index, something like this:

    index('[sheet1fileB.xls]Sheet1'!$A$2:$A$3000,LARGE(IF('[sheet1fileB.xls.xls]Sheet1'!$F$2:$F$3000=B3,ROW(1:3000)),1))

    STILL, the result isn't correct. There was no grammar mistake, above command is written here for demostration purpose only, so I need you people to do me a farvor:


    1, tell me if lookup func is the right path to go, and tell me how to compose the correct command line

    2, if lookup won't work, please tell me if there is some LOGIC flaws reflected in my INDEX sentence posted above? For example, I want to realize the purpose A, but my line took me to B. And again, tell me how to compose/modify it.

    Thanks a lot!

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

    Re: Find the last-row result of multiple matches?

    The approach you have used is not wrong per se though:

    a) it does require array entry (ie must be confirmed with CTRL + SHIFT + ENTER and not just Enter per "normal" formulae)

    b) You should really adjust

    ROW(1:3000)

    to either

    ROW($1:$2999)

    or preferably

    ROW($A$2:$A$3000)-ROW($A$2)+1


    Another alternative approach would be:

    =LOOKUP(2,1/('[sheet1fileB.xls.xls]Sheet1'!$F$2:$F$3000=B3),'[sheet1fileB.xls.xls]Sheet1'!$A$2:$A$3000)
    confirmed with Enter
    Note that even though the above does not require Array entry it is not very efficient (either)

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

    Re: Find the last-row result of multiple matches?

    or arrayformula ?

    PHP Code: 
    =INDEX('[fileB.xls]Sheet1'!$F$2:$G$3000,MAX(IF('[fileB.xls]Sheet1'!$F$2:$F$3000=B3,ROW($F$2:$F$3000)-1,0)),2
    Last edited by snb; 07-08-2011 at 08:48 AM.



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

    Re: Find the last-row result of multiple matches?

    @snb, yes, I think that is similar to OP's original formula (MAX rather than LARGE), however, you need to adjust either your use of ROW or initial INDEX range - as is you are offsetting by 1 row.

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

    Re: Find the last-row result of multiple matches?

    @DO

    Sure !
    I amended the code. (I overlooked that because I tested on my system using F1:F3000).

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Find the last-row result of multiple matches?

    Quote Originally Posted by DonkeyOte View Post
    @snb, yes, I think that is similar to OP's original formula (MAX rather than LARGE),.......
    There is a difference, though, if there are no rows that meet the criteria. MAX will return zero and LARGE will return an error. The former is a problem because when the zero is fed to the INDEX function the whole column is returned. Here because only a single value can be returned by the formula that manifests itself as the contents of G2 - hence an erroneous result.......better to get the error with LARGE.......
    Last edited by daddylonglegs; 07-08-2011 at 11:30 AM.
    Audere est facere

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

    Re: Find the last-row result of multiple matches?

    wouldn't this suffice ?

    PHP Code: 
    =if(countif('[fileB.xls]Sheet1'!$F$2:$F$3000,B3)=0,"",INDEX('[fileB.xls]Sheet1'!$F$2:$G$3000,MAX(IF('[fileB.xls]Sheet1'!$F$2:$F$3000=B3,ROW($F$2:$F$3000)-1,0)),2)) 

+ 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