+ Reply to Thread
Results 1 to 10 of 10

Match data in 2 columns and return all results from a 3rd to a single cell

  1. #1
    Registered User
    Join Date
    07-27-2017
    Location
    UK
    MS-Off Ver
    2012
    Posts
    43

    Match data in 2 columns and return all results from a 3rd to a single cell

    Hi all,
    I have a spreadsheet that has 3 columns of data. I need to match results from 2 of the columns and return all the results from the corresponding 3rd column into a single cell. I have found some code that does this for a single search but I don't know how to expand this to search in an additional column. This code is below. Please could someone help?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    Upload sample workbook, with desensitized raw data, along with expected output.

    To attach a file, use "Go Advanced" button found at bottom right of edit/quick reply. Then click on "Manage Attachments" hyperlink. It will launch new window/tab.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    07-27-2017
    Location
    UK
    MS-Off Ver
    2012
    Posts
    43

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    Hi, ok thanks attachment uploaded.

    In this file, columns F and G contain that data that will be looked up and matched in columns B and C and then output the corresponding matches from columns A into a single cell in column I. The data in A, B and C will be continually added to.

    Hope that makes sense? Cheers.
    Attached Files Attached Files
    Last edited by aidan5800; 07-23-2018 at 05:51 AM.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try ths ‼


    As a starter :

    PHP Code: 
    Sub Demo1()
             
    Dim VWR&, K$
        
    With Sheet1
                 V 
    = .[F6].CurrentRegion.Value
                 W 
    = .[A6].CurrentRegion.Value
            With 
    New Dictionary
                
    For 1 To UBound(W)
                    
    W(R2) & " " W(R3)
                    If .
    Exists(KThen .Item(K) = .Item(K) & ", " W(R1) Else .Item(K) = W(R1)
                
    Next
                    
    For 1 To UBound(V):  V(R1) = .Item(V(R1) & " " V(R2)):  Next
                   
    .RemoveAll
            End With
                
    .[I6].Resize(UBound(V)).Value V
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Registered User
    Join Date
    07-27-2017
    Location
    UK
    MS-Off Ver
    2012
    Posts
    43

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    When I try and use this I get a compile error on New Dictionary. Did you manage to successfully run on the uploaded file? Should it go in thisworkbook or the sheet code?

    Thanks

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    UDF

    I6:
    =VLookUps(F6,G6,$A$6:$C$28,", ")
    then filldown.

    Please Login or Register  to view this content.
    You need to set the calculation mode to Automatic.
    Last edited by jindon; 07-23-2018 at 06:55 AM.

  7. #7
    Registered User
    Join Date
    07-27-2017
    Location
    UK
    MS-Off Ver
    2012
    Posts
    43

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    Hi, I'm now getting #NAME? error?

    Also, if the data to lookup is on another sheet, how would this be achieved? New file uploaded.

    Many thanks.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    1) Code needs be pasted in a Standard module.
    2) Set the calculation mode to automatic.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-27-2017
    Location
    UK
    MS-Off Ver
    2012
    Posts
    43

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    brilliant many thanks!

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match data in 2 columns and return all results from a 3rd to a single cell

    You are welcome and 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.

+ 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] Return value 2 columns to left of cell in single row
    By AndyGW in forum Excel General
    Replies: 6
    Last Post: 06-05-2016, 07:03 PM
  2. [SOLVED] Formula to locate and match multiple data and return results
    By hammer2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-20-2015, 09:27 PM
  3. Replies: 4
    Last Post: 09-04-2014, 01:24 PM
  4. Using Index And Match To Return Potential Multiple Results To One Cell
    By jcaynes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-11-2013, 10:41 AM
  5. Using Index Match to return multiple results with very messy data.
    By falkon007 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 01-30-2013, 12:28 PM
  6. Match Single Cell and Return Row Macro Not Working
    By Steve0492 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2012, 03:44 PM
  7. [SOLVED] lookup multiple values of a single cell and return sum of results
    By Zeppelin17 in forum Excel General
    Replies: 7
    Last Post: 08-10-2011, 07:09 PM

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