Silverbird09
New Member
- Joined
- Mar 2, 2017
- Messages
- 2
Good Afternoon,
First of all I want to say I am a long time reader, first time poster on MrExcel. Because of this board, as well as others, I have become quite skilled in matters of Excel and Access (or at least been good at finding what I need at the time). However I have been unable to find the answer to my current question, perhaps I'm addressing it incorrectly.
Ok, enough of that, here is my scenario:
I have two tables with corresponding table structures. The only difference is one includes a Primary Key (MainTable), the other doesn't (ImportTable). The primary key is auto-generated during appending to MainTable. The intent is to use ImportTable to append new records into MainTable. The important columns include:
MainTable
Legacy_ID (Primary Key) -- Project_ID -- SKU_ID
ImportTable
Project_ID -- SKU_ID
The idea is to first check for duplicate SKU_ID's between the two tables before appending. However, there can be duplicates if the Project_ID's are different. I want to avoid duplicate results as shown in the example below:
MainTable (Duplicates Exist)
[TABLE="width: 400"]
<tbody>[TR]
[TD]Legacy_ID (Primary Key)[/TD]
[TD]Project_ID[/TD]
[TD]SKU_ID
[/TD]
[/TR]
[TR]
[TD]1001[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1002[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1003[/TD]
[TD]2[/TD]
[TD]IMP-1013[/TD]
[/TR]
[TR]
[TD]1004[/TD]
[TD]2[/TD]
[TD]IMP-3922[/TD]
[/TR]
</tbody>[/TABLE]
MainTable (No Duplicates Exist)
[TABLE="width: 400"]
<tbody>[TR]
[TD]Legacy_ID (Primary Key)[/TD]
[TD]Project_ID[/TD]
[TD]SKU_ID
[/TD]
[/TR]
[TR]
[TD]1001[/TD]
[TD]1[/TD]
[TD]IMP-1245[/TD]
[/TR]
[TR]
[TD]1002[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1003[/TD]
[TD]2[/TD]
[TD]IMP-1013[/TD]
[/TR]
[TR]
[TD]1004[/TD]
[TD]2[/TD]
[TD]IMP-0002
[/TD]
[/TR]
</tbody>[/TABLE]
Hopeful I was able to explain that accurately. Thank you in advance for your thoughts and advice.
P.S. - I tried to find a similar question, but was unable to find a solution. I apologize in advance if I inadvertently duplicated this specific question.
First of all I want to say I am a long time reader, first time poster on MrExcel. Because of this board, as well as others, I have become quite skilled in matters of Excel and Access (or at least been good at finding what I need at the time). However I have been unable to find the answer to my current question, perhaps I'm addressing it incorrectly.
Ok, enough of that, here is my scenario:
I have two tables with corresponding table structures. The only difference is one includes a Primary Key (MainTable), the other doesn't (ImportTable). The primary key is auto-generated during appending to MainTable. The intent is to use ImportTable to append new records into MainTable. The important columns include:
MainTable
Legacy_ID (Primary Key) -- Project_ID -- SKU_ID
ImportTable
Project_ID -- SKU_ID
The idea is to first check for duplicate SKU_ID's between the two tables before appending. However, there can be duplicates if the Project_ID's are different. I want to avoid duplicate results as shown in the example below:
MainTable (Duplicates Exist)
[TABLE="width: 400"]
<tbody>[TR]
[TD]Legacy_ID (Primary Key)[/TD]
[TD]Project_ID[/TD]
[TD]SKU_ID
[/TD]
[/TR]
[TR]
[TD]1001[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1002[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1003[/TD]
[TD]2[/TD]
[TD]IMP-1013[/TD]
[/TR]
[TR]
[TD]1004[/TD]
[TD]2[/TD]
[TD]IMP-3922[/TD]
[/TR]
</tbody>[/TABLE]
MainTable (No Duplicates Exist)
[TABLE="width: 400"]
<tbody>[TR]
[TD]Legacy_ID (Primary Key)[/TD]
[TD]Project_ID[/TD]
[TD]SKU_ID
[/TD]
[/TR]
[TR]
[TD]1001[/TD]
[TD]1[/TD]
[TD]IMP-1245[/TD]
[/TR]
[TR]
[TD]1002[/TD]
[TD]1[/TD]
[TD]IMP-0002[/TD]
[/TR]
[TR]
[TD]1003[/TD]
[TD]2[/TD]
[TD]IMP-1013[/TD]
[/TR]
[TR]
[TD]1004[/TD]
[TD]2[/TD]
[TD]IMP-0002
[/TD]
[/TR]
</tbody>[/TABLE]
Hopeful I was able to explain that accurately. Thank you in advance for your thoughts and advice.
P.S. - I tried to find a similar question, but was unable to find a solution. I apologize in advance if I inadvertently duplicated this specific question.