+ Reply to Thread
Results 1 to 8 of 8

Searching multiple columns

  1. #1
    Registered User
    Join Date
    12-01-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Searching multiple columns

    So I have this problem, please see attached picture excel.png

    I want to do a lookup on each value in columns A-C and return the value in D in a row in column G. I came up with a formula using the if and vlookup function but its huge and I know that there is a simpler way.

    So in G2 lookup Value32 in column A if it's found then return value in D if not then move to column B and if found return value in D if not then go to C etc etc.

    Any help much appreciated.
    Attached Images Attached Images

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Searching multiple columns

    Hi.

    An actual workbook would be much preferable to a picture or two.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    12-01-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching multiple columns

    So I've attached a workbook. So when I search for "Value 32" I want it to return the number "11". Not really sure how the formula looks like.
    Attached Files Attached Files

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Searching multiple columns

    Thanks.

    There does not appear to be a space in your entry in cell F2 (Value32), though there is in that in cell B12 (Value 32), which will obviously need to be rectified so that this solution will work.

    Assuming that each entry in the range A2:C31 can only ever occur once, in G2:

    =INDEX($D$2:$D$31,SUMPRODUCT(($A$2:$C$31=F2)*(ROW($A$2:$C$31)-MIN(ROW($A$2:$C$31))+1)))

    Copy down as required.

    Regards

  5. #5
    Registered User
    Join Date
    12-01-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching multiple columns

    Thanks, that's very helpful. However it seems to return the first value if that ID is not located in the list or provide me a #REF. I've attached a more appropriate workbook now that I've got access to my computer. So it will search for the ID in column H through columns A-E and return the corresponding value in column F. By the way there will be duplicates within this list so if it does see a duplicate or the ID is not found then return a N/A.

    Cheers

    I should also add this would also be applied to search those IDs and return text. Would much tweaking need to be applied to the formula to return text?
    Attached Files Attached Files
    Last edited by testsubjectzz; 02-17-2015 at 07:12 PM.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Searching multiple columns

    Ah yes. Apologies. I did not consider cases where the search value was not found anywhere.

    My previous formula should be:

    =IF(COUNTIF($A$2:$C$31,F2),INDEX($D$2:$D$31,SUMPRODUCT(($A$2:$C$31=F2)*(ROW($A$2:$C$31)-MIN(ROW($A$2:$C$31))+1))),"Not Found")

    I trust you can adapt this to work for the set-up in your new workbook?

    It does not matter if the values in the column to be returned are text or numeric using this solution.

    Regards

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Searching multiple columns

    Also array formula to prevent duplicates

    =IF(OR(ROWS(F$2:F2)>COUNTA(F:F)-1,COUNTIF(A$2:C$31,F2)>1),"N/A",MAX(IF(A$2:C$31=F2,ROW(A$2:C$31)-1),0))

    ***Array formula must be entered by using key combination of CTRL+SHIFT+ENTER and not just ENTER
    Last edited by AlKey; 02-17-2015 at 07:41 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Registered User
    Join Date
    12-01-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching multiple columns

    Wow thanks guys, much appreciated. So AlKey I could use that formula instead?

+ 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. [SOLVED] Searching for multiple terms in multiple cell columns
    By damianrichman in forum Excel General
    Replies: 4
    Last Post: 03-18-2014, 11:47 PM
  2. Searching multiple columns
    By Erenagh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2011, 01:31 PM
  3. Searching multiple columns
    By BRISBANEBOB in forum Excel General
    Replies: 1
    Last Post: 12-19-2008, 03:47 AM
  4. Searching multiple columns for keywords
    By tranh in forum Excel - New Users/Basics
    Replies: 14
    Last Post: 12-17-2007, 02:57 PM
  5. [SOLVED] Searching multiple columns
    By Robin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-12-2005, 11:05 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