+ Reply to Thread
Results 1 to 4 of 4

Find all matching values in two tables and return identifier

  1. #1
    Registered User
    Join Date
    06-28-2018
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2018
    Posts
    4

    Lightbulb Find all matching values in two tables and return identifier

    Hi All,

    I have two tables, for both I have two options of presenting the data: (the data is just an example, the actual dataset is way bigger)

    Table A1
    Customer_ID | Purchased UPCs
    43610023099 | 102
    43610023099 | 5
    43610023099 | 10
    43610023090 | 102
    43610023090 | 20
    43610023090 | 15

    Table A2
    Customer_ID | Purchased UPCs
    43610023099 | 102, 5, 10
    43610023090 | 102, 20, 15

    Table B1
    Coupon_ID | Connected UPCs
    Coupon_1 | 102
    Coupon_1 | 3
    Coupon_2 | 20
    Coupon_2 | 11

    Table B2
    Coupon_ID | Connected UPCs
    Coupon_1 | 102, 3
    Coupon_2 | 20, 11

    What I am trying to do is basically the following:
    If any UPC of a customer matches any UPC of a Coupon, return that Coupon.

    So I just want to show that they are connected through the UPC.
    The result could be anything from:

    Customer_1 | Coupon_1
    Customer_1 | Coupon_3
    Customer_2 | Coupon_2

    or

    Customer_1 | Coupon_1, Coupon_3
    Customer_2 | Coupon_2

    or

    Coupon_1 | Customer_1
    Coupon_2 | Customer_2
    Coupon_3 | Customer_1

    I am willing to do Macros in order to achieve this. And I thought about using a Match function with IF and eventually Arrays? But I am really struggeling to make something up that works.

    PLEASE HELP!
    Last edited by Nora Kro; 08-21-2018 at 11:49 AM.

  2. #2
    Forum Contributor
    Join Date
    07-05-2012
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Find all matching values in two tables and return identifier

    Take a look at the attached spreadsheet. I have named each table (both version '1') and done a 'vlookup' and 'concatenation' to create a conjoined field. The results are then displayed in a pivot table.
    Attached Files Attached Files
    Click on the * icon if this post has been helpful.

  3. #3
    Forum Contributor
    Join Date
    03-28-2018
    Location
    Houston, TX
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    127

    Re: Find all matching values in two tables and return identifier

    The file posted above doesn't seem correct, as it has lines for each instance, even when there is not a match.

    My solution incorporates VBA. I think VBA is the best approach here since you said the data sets are large. Using formulas or pivots will bog down the workbook and can get very messy. I have attached a workbook with the VBA code in it along with your sample data. I think using Table A1 and Table B1 is probably the cleanest way to tackle this problem. You can take the full data sets, post them in the "Table A1" and "Table B1" tabs and then use the button in the "List" tab to run the macro and get your results.

    Let me know if you have any questions.

    Thanks!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-28-2018
    Location
    Narragansett, Rhode Island
    MS-Off Ver
    Excel 2018
    Posts
    4

    Cool Re: Find all matching values in two tables and return identifier

    Thank you so much for the quick and great response! That macro works perfectly

+ 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. Replies: 3
    Last Post: 06-01-2015, 01:16 PM
  2. [SOLVED] Find matching values and return
    By Drayde in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-17-2014, 12:24 PM
  3. Replies: 3
    Last Post: 01-03-2014, 08:03 PM
  4. Replies: 2
    Last Post: 12-04-2013, 09:45 PM
  5. Replies: 2
    Last Post: 09-07-2013, 07:50 PM
  6. Find, add and return values from multiple tables.
    By Excelmad101 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-13-2013, 07:52 PM
  7. Find minimum for all values with same identifier within an array
    By dhs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2011, 10:48 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