+ Reply to Thread
Results 1 to 8 of 8

How to look up a value in a list and return multiple corresponding values

  1. #1
    Registered User
    Join Date
    12-06-2006
    Posts
    4

    How to look up a value in a list and return multiple corresponding values

    Hi All,

    I was wondering if someone could help me with an excel problem i am having. If you do offer help, you will need to explain things for a dummy.

    I've treid looking on Online Office help but unless you understand their short hand on things it doesn't really help. For instance they mention (CTRL+SHIFT+ENTER) which i have no idea what they mean.

    The problem i have is looking up references. For Instance if i have column A as a list of order numbers, then column F as a list of product codes that relate to the order numbers.

    On another sheet i have a list of the similar order numbers, but what i want to do on this sheet is pull the product codes from the previous sheet through to this one by refering it to the order number...

    For example

    Sheet one
    Order Number Product
    05555 A
    05554 B
    05554 A
    05553 A
    05553 C
    05553 B

    Sheet 2
    Order Number Products Following Column
    05554 ??(should be B) ??(should be A)

    Hope this makes sense?

    Many thanks
    Regards
    The Rat

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    Heres a post for a VLOOKUP example
    http://www.excelforum.com/showthread...hlight=vlookup

    If you can't use the vlookup, then you could try the filter
    select a cell in the data range
    goto data,filter
    select autofiltr
    hit the down arrow at the top of a column and make a selection
    see what happens

  3. #3
    Registered User
    Join Date
    12-06-2006
    Posts
    4
    Hi,

    Thanks, but VLookup only gives me 1 product code back for the order number, whereas the order number will have, say... 5 product codes listed to it. I need all 5 product codes to come back..

    Regards

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by SteelRat
    Hi,

    Thanks, but VLookup only gives me 1 product code back for the order number, whereas the order number will have, say... 5 product codes listed to it. I need all 5 product codes to come back..

    Regards
    hi

    courtesy of another Forum member - -

    If you want to lookup a value in C1 within A1:A10 and return a value from B1:B10 but there might be multiple matches and you want to return all of them....use this formula in D1 copied down

    =IF(COUNTIF(A$1:A$10,C$1)>ROW()-ROW(D$1),INDEX(B$1:B$10,SMALL(IF(A$1:A$10=C$1,ROW( A$1:A$10)-ROW(A$1)+1),ROW()-ROW(D$1)+1)),"")

    confirmed with CTRL+SHIFT+ENTER


    hth
    ---
    Si fractum non sit, noli id reficere.

  5. #5
    Registered User
    Join Date
    12-06-2006
    Posts
    4
    Hi,

    Again, thank you. However a couple of things..

    To get more than 1 return i have to copy down, what if i want to copy right. i.e i want to follow the same results horizonally along the row not vertically along the column?

    Also, does this work if the data sheet you are looking up is on another worksheet (not workbook). eg. i have the data on sheet 3 and i want the results to come back on sheet 1?

    Many thanks
    Regards
    The Rat

  6. #6
    Forum Contributor
    Join Date
    10-27-2006
    Location
    United Kingdom
    MS-Off Ver
    EXCEL 2003 (2007 at home)
    Posts
    517

    Talking [Ctrl+Shift+Enter]

    [Ctrl+Shift+Enter] indicates that you simultaneously press
    the ctrl key (bottom left and bottom right of main alpabet keypad)
    the shift key (marked with an up arrow and just above the ctrl key)
    the enter key (also known as return, on the right just above the shift)
    (at least that is where they are on my keyboard).

    When I say simultaneously it is actually usual to press ctrl first, but keep it held down, then shift (keep them both down) then enter, and finally release them all.This combination tells Excel to treat the formula differently from normal.

    Instead of assuming that there is a single set of values to be passed through the formula, [ctrl+shift+enter] indicates that there is a range (or array) of values to be passed through the same formula. The resultant formula is displayed in {brackets} to show its special status.

    This is quite an advanced concept, which is tricky to get ones head round.
    But if you can master it, there are things you can do which are hard or even imposible to achieve any other way.

    Mark.

  7. #7
    Forum Contributor
    Join Date
    10-27-2006
    Location
    United Kingdom
    MS-Off Ver
    EXCEL 2003 (2007 at home)
    Posts
    517

    Without ctrl+shift+enter

    I think your problem could be solved using MATCH(), OFFSET() and INDEX() and additional "helper" rows, which might be easier for a novice to cope with than the tricky array formulas.

    Assume Row 1 is the headings (order number; product 1; product 2...)
    A2 not used
    A3 ="05554"
    B2 =MATCH($A3,Sheet1!$A2:$A1000,0) ... find the first match
    C2 =MATCH($A3,OFFSET(Sheet1!$A$2,B2,0,1000),0)+B2 second match
    Replicate C2 across as required for the number of products, thus:
    D2 =MATCH($A3,OFFSET(Sheet1!$A$2,C2,0,1000),0)+C2
    etc...
    B3 =INDEX(Sheet1!$B$2:$B$1000,B2,1)
    Replicate B3 across as required for the number of products, thus:
    C3 =INDEX(Sheet1!$B$2:$B$1000,C2,1)
    By replicate I mean select the cell, point to the bottom right hand corner, then click and drag.

    Then copy and paste rows 2&3 onto rows 4&5 for the next order
    and repeat for each order.

    The key function here is OFFSET() which causes each subsequent MATCH() to start where the last finished.

    Mark.

  8. #8
    Registered User
    Join Date
    12-06-2006
    Posts
    4
    Quote Originally Posted by Bryan Hessey
    hi

    courtesy of another Forum member - -

    If you want to lookup a value in C1 within A1:A10 and return a value from B1:B10 but there might be multiple matches and you want to return all of them....use this formula in D1 copied down

    =IF(COUNTIF(A$1:A$10,C$1)>ROW()-ROW(D$1),INDEX(B$1:B$10,SMALL(IF(A$1:A$10=C$1,ROW( A$1:A$10)-ROW(A$1)+1),ROW()-ROW(D$1)+1)),"")

    confirmed with CTRL+SHIFT+ENTER


    hth
    ---
    Mark, what you have put seems far to confusing... The previous person put the above formula, which i have working well at the moment, however i have 1 problem with the above formula, which is....

    As i wanted the results to run horizontally from left to right across the spreadsheet, using the above means the results running vertically top to bottom. I resolved this problem by changing the last 2 "ROW"'s to "COLUMN" and it now works horizontally if i cut and paste and (CTRL+SHIFT+ENTER) however, when i did the vertically, all cells i put this formula in that had no results would show as blank, but when it try it horizontally, it comes up #NUM! which i can't seem to work out how to change?

    Any help on this one?
    Last edited by SteelRat; 12-06-2006 at 12:14 PM.

+ 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