+ Reply to Thread
Results 1 to 10 of 10

How to map two tables

  1. #1
    Registered User
    Join Date
    02-11-2022
    Location
    France
    MS-Off Ver
    2021
    Posts
    10

    How to map two tables

    Hello,

    I have a first table of n rows (in the attached example, this first table has 14 rows)
    Each item has a unique ID :
    First table.png

    Then, I have a 2nd table with less items (sometimes it is 25% less, sometimes it can be up to 90% less). Also, in this table, the rows have a different order than in the first table: they are all mixed up!
    Furthermore, this table can contain new rows (which are not contained in the first table).
    2nd table.png

    I am (desperately) looking for a VBA script (or formulas?) to automatically make a "mapping" between these two tables, i.e. to add, in the first table, the price of each item from the second table (as long as the item from the second table was already present in the first table).

    Anyone knows how to do that please? All help is welcome!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to map two tables

    Hi and welcome to the forum

    In D5 copied down

    =IFERROR(VLOOKUP(A5,$F$5:$G$14,2,FALSE),"")
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to map two tables

    As per you excel version, you can use PQ( Get and transform) function.
    Last edited by AB33; 02-11-2022 at 12:31 PM.

  4. #4
    Registered User
    Join Date
    02-11-2022
    Location
    France
    MS-Off Ver
    2021
    Posts
    10

    Re: How to map two tables

    Thank you Richard for your answer. I have tried but I get this error message:
    Attachment 767728

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to map two tables

    Quote Originally Posted by laura6776 View Post
    Thank you Richard for your answer. I have tried but I get this error message:
    Attachment 767728
    Please upload the workbook in which you get that message.

  6. #6
    Registered User
    Join Date
    02-11-2022
    Location
    France
    MS-Off Ver
    2021
    Posts
    10

    Re: How to map two tables

    Here is the workbook. I have commented the formula you advised me to put in, otherwise it was not possible to save the file.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to map two tables

    As Richard is off
    Put this formula in D5 as per attached and drag it down.

    =IFERROR(VLOOKUP(A5,$F$5:$G$14,2,0),0)
    Last edited by AB33; 02-11-2022 at 02:05 PM.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to map two tables

    Could easily used PQ

    Please Login or Register  to view this content.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to map two tables

    Quote Originally Posted by laura6776 View Post
    Here is the workbook. I have commented the formula you advised me to put in, otherwise it was not possible to save the file.
    You did not use the formula I gave you.

    You used

    =IFERROR(VLOOKUP(D5:$G$14,2,FALSE),"")

    In gave you

    =IFERROR(VLOOKUP(A5,$F$5:$G$14,2,FALSE),"")

    Your formula did not contain the first element of a VLOOKUP, i.e. the value to use in the first column of the range containing the data you want, i..e A5 which contains the ID. Furthermore the range you were lookingup was D5:G14 and not F5:F14

  10. #10
    Registered User
    Join Date
    02-11-2022
    Location
    France
    MS-Off Ver
    2021
    Posts
    10

    Re: How to map two tables

    Whoooo AMAZING! Richard's solution works... just perfectly! I have not tried the other ones since this one seems simpler to me.
    Thanks everyone for your help!

    5a6f313e480491b12cd39e27630a5e75.jpg

+ 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. Filter multiple tables and columns and automaticall add new tables to macros
    By HarleyRidesBMX in forum Access Tables & Databases
    Replies: 2
    Last Post: 08-29-2021, 10:08 AM
  2. Replies: 1
    Last Post: 12-01-2019, 01:13 PM
  3. Smaller tables feeding into larger tables / gantt charts
    By Wraig1985 in forum Excel General
    Replies: 1
    Last Post: 03-16-2018, 10:24 AM
  4. Replies: 5
    Last Post: 12-04-2017, 10:33 AM
  5. Excel Automation: Updating Pivot Tables, Charts, and Tables
    By Lemguin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-03-2015, 04:25 AM
  6. Multiple Data Tables Link and Calculate onto Target Tables
    By billexchry in forum Excel General
    Replies: 6
    Last Post: 03-04-2011, 02:42 PM

Tags for this Thread

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