+ Reply to Thread
Results 1 to 24 of 24

Lookup in Multiple Columns and return a string

  1. #1
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Lookup in Multiple Columns and return a string

    I have a table that pulls data in, but it's in a random order. I've been trying to use a lookup functions that will reorganize it, but because one of the text it's looking up isn't in the first column I'm getting alot of wrong results.

    I need to search A2 and look through F2:H16 and when it finds a hit, it will copy F:H as is in that order (Hopefully it's possible) I've attached a picture and in A:D is how I'd hope the results would go.


    Screen Shot 2017-08-30 at 5.25.47 PM.png

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Try this in B2 and drag copy across to D2 and then down:

    =VLOOKUP(A2,$F2:F16,COLUMNS($B2:B2),0)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    I was using the vlookup and it seems when I get to Raiders, it comes up with an error because it's in Column H and not F.

    I'm currently trying Match/Index to see if that will do what is needed

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Please clarify the order in which you want to display the data. It is not clear.

  5. #5
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    The correct order is how A2:A4, but I need it to still keep the order of how it appears in the rows in F:H

    So I need to find Raiders and return Titans 1 Raiders
    Find Cards, Returns Cards 1 Lions
    Is this even a possibility ?

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Yes, but what I am getting at is how will the list grow? What comes next after Raiders. There is no logic I can see in the order in which the teams are appearing in column A. What am I missing?

    You will need to establish an INDEX MATCH that first looks up column F and if it finds nothing, column H. Once you have established which row the searched for team is on, the rest is easy. I'm afraid I'm away from my PC now, and have run out of time this evening.
    Last edited by AliGW; 08-31-2017 at 01:10 AM.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    Beh162 please upload a workbook. It saves retyping data. I have an idea, but am busy doing other formulas as well.
    Dave

  8. #8
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    Okay I've uploaded a sample book.

    I'm currently working on Match and Index to see how that may work for this.
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    486

    Re: Lookup in Multiple Columns and return a string

    Try the following in your Test Workbook:

    - Select range B1:D1
    - Paste this formula in the Formula Bar =INDEX($F$1:$H$4,MATCH("*"&A1&"*",$F$1:$F$4&$H$1:$H$4,0),0)
    - Press Cmd+Return to enter the array formula (note: please check your Excel help for the key combination)
    - Drag-copy the three selected cells down
    Last edited by Root_; 08-30-2017 at 10:37 PM.

  10. #10
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    I got an NA error. Would array be my best option, or would other formula's work without Array? Curious

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    Like AliGW suggests make room for growth. A dynamic named range is good for this.

    In Name Manager this formula which I named TeamList
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then this formula in B1 filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    Okay awesome - I'm going to look into this and put it into my live data and see.

    I appreciate the help alot

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    Before you get away here's a simpler formula. It does have to be array entered. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    With the same dynamic named range.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    I will also practice on that. I do like the addition of dynamic named range. I never explored that

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    Late Edit: Ignore this one. It won't handle return matches. FR

    Here's a shorter one. It does not have to be array entered.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 08-31-2017 at 01:48 PM.

  16. #16
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,980

    Re: Lookup in Multiple Columns and return a string

    Or try this ...

    =INDEX(F:F,SMALL(IF($F$1:$H$100=$A1,ROW($F$1:$H$100)),1))

    Enter with Ctrl+Shift+Enter

  17. #17
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    @ Phuocam How do you index for column H when items in column A are in column F?
    Last edited by FlameRetired; 08-31-2017 at 12:48 AM.

  18. #18
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,980

    Re: Lookup in Multiple Columns and return a string

    Quote Originally Posted by FlameRetired View Post
    @ Phuocam How do you index for column H when items in column A are in column F?
    Maybe?

    =INDEX(INDIRECT(IF(LARGE(IF($F$1:$H$100=$A1,COLUMN($F$1:$H$100)),1)=8,"F:F","H:H")),
    LARGE(IF($F$1:$H$100=$A1,ROW($F$1:$H$100)),1))

  19. #19
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,424

    Re: Lookup in Multiple Columns and return a string

    OK. Why INDIRECT? Your formula works without it.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Try this (enter each separately, then drag copy all three down):

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    1
    Jets Jets
    7
    Bills
    2
    Falcons Falcons
    5
    Bears
    3
    Raiders Raiders
    1
    Titans
    4
    Patriots Patriots
    8
    Chiefs
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    B
    C
    D
    1
    =IFNA(INDEX($F$1:F$4,MATCH($A1,$F$1:$F$4,0)),INDEX($H$1:H$4,MATCH($A1,$H$1:$H$4,0)))
    =INDEX($G$1:G$4,IFERROR(MATCH($A1,$F$1:$F$4,0),MATCH($A1,$H$1:$H$4,0)))
    =IFNA(INDEX($F$1:F$4,MATCH($A1,$H$1:$H$4,0)),INDEX($H$1:H$4,MATCH($A1,$F$1:$F$4,0)))
    Sheet: Sheet1

  21. #21
    Forum Contributor
    Join Date
    01-15-2015
    Location
    New York
    MS-Off Ver
    Excel 2011 MAC
    Posts
    104

    Re: Lookup in Multiple Columns and return a string

    AliGM

    This one did work, but the problem is when it searched for Raiders it reverse how it needed to appear. It should be Titans 1 Raiders.

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Explain your logic for Titans coming first.

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    1
    Jets Jets
    7
    Bills Patriots
    8
    Chiefs
    2
    Falcons Falcons
    5
    Bears Bills
    7
    Jets
    3
    Raiders Raiders
    1
    Titans Falcons
    5
    Bears
    4
    Patriots Patriots
    8
    Chiefs Titans
    1
    Raiders
    Sheet: Sheet1

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Try changing B1 to this:

    =IFNA(INDEX($F$1:F$4,MATCH($A1,$F$1:$F$4,0)),INDEX($F$1:F$4,MATCH($A1,$H$1:$H$4,0)))

    and D1 to this:

    =IFNA(INDEX($H$1:H$4,MATCH($A1,$F$1:$F$4,0)),INDEX($H$1:H$4,MATCH($A1,$H$1:$H$4,0)))

  24. #24
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Lookup in Multiple Columns and return a string

    Thanks for the rep!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. LOOKUP to return values from multiple columns
    By Just Mike in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 06-01-2017, 04:41 PM
  2. Lookup multiple columns and return a value
    By lvan87 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-10-2014, 08:00 AM
  3. [SOLVED] Lookup multiple columns and return a value
    By coach.32 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-10-2014, 12:13 AM
  4. Replies: 0
    Last Post: 10-16-2013, 12:42 PM
  5. lookup multiple values in multiple columns to return a result
    By AYAHOO123 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-11-2013, 07:53 PM
  6. Lookup then Search for text string and return multiple entries
    By tnewell2 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-24-2012, 12:11 PM
  7. Replies: 1
    Last Post: 10-17-2010, 03:26 AM

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