Compare two Sheet (same criteria one column) and Create new sheet with matches

jmery24

New Member
Joined
Jul 20, 2018
Messages
3

Hello againThank you first of all.

I need to compare 2 sheets, which have a single data in common and with that data create a new sheet.
Nro TKT in both sheets is a KEY to find matches

For example.
Sheet1

Nro TKt - Column AName - Column BFecha - Column CTotal - Column D
123456Juan25/05/181500.00
123457Pablo25/05/181800.00
234567Pedro26/05/18-5000.00
985285John27/05/180.00
985286MAteo30/05/18-120

<tbody>
</tbody>

Sheet2

Nro TKt - Column ACia - Column BName - Column CFecha - Column DTotal - Column E
12345645Juan25/05/181500.00
12345744Pablo25/05/181750.00
23456645Maria26/05/18-4500.00
985285230John27/05/18-300.00
12345855Carlos25/05/1812500.00
456789220Estela26/05/18135500.00

<tbody>
</tbody>


Expects Results
Create Sheet3
DIF (columnB) = Total.Sheet1 - Total.Sheet2

Match - New - Column ADif - New - Column BNro Tkt - Sheet1 - Column C Name - Sheet1 - Column DFecha - Sheet1 - Column ETotal - Sheet1 - Column F
Nro Tkt - Sheet2 - Column GCia - Sheet2 - Column HName - Sheet2 - Column IFecha - Sheet2 - Column JTotal - Sheet2 - Column K
OK0.00123456Juan25/05/181500.0012345645Juan25/05/181500.00
OK50.00123457Pablo25/05/181800.0012345744Pablo25/05/181750.00
NO-5000.00234567Pedro26/05/18-5000.00
OK300.00985285John27/05/180.00985285230John27/05/18-300
NO-120.00985286Mateo30/05/18-120.00
NO-12500.012345855Carlos25/05/1812500.00
NO-135500.00456789220Estela26/05/18135500.00
NO4500.0023456645Maria26/05/18-4500.00

<tbody>
</tbody>

Thanks
I do not know how to start
Juan Manuel
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
if you allowed to use PowerQuery (2010/2013 add-in, 2016 built-in) you can try load two table into PQ then merge them by col.A with FullOuter, change null to 0, add custom column for differences and add conditional column to compare columns A (sheet1) and column A (sheet2)
Code:
let
    Source = Table.NestedJoin(Table1,{"Nro TKt - Column A"},Table2,{"Nro TKt - Column A"},"Table2",JoinKind.FullOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"Nro TKt - Column A", "Cia - Column B", "Name - Column C", "Fecha - Column D", "Total - Column E"}, {"Table2.Nro TKt - Column A", "Table2.Cia - Column B", "Table2.Name - Column C", "Table2.Fecha - Column D", "Table2.Total - Column E"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Table2",null,0,Replacer.ReplaceValue,{"Total - Column D"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",null,0,Replacer.ReplaceValue,{"Table2.Total - Column E"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value1", "Diff", each [#"Total - Column D"]-[#"Table2.Total - Column E"]),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Diff", "Nro TKt - Column A", "Name - Column B", "Fecha - Column C", "Total - Column D", "Table2.Nro TKt - Column A", "Table2.Cia - Column B", "Table2.Name - Column C", "Table2.Fecha - Column D", "Table2.Total - Column E"}),
    #"Added Conditional Column" = Table.AddColumn(#"Reordered Columns", "Match", each if [#"Nro TKt - Column A"] = [#"Table2.Nro TKt - Column A"] then "OK" else "NO"),
    #"Reordered Columns1" = Table.ReorderColumns(#"Added Conditional Column",{"Match", "Diff", "Nro TKt - Column A", "Name - Column B", "Fecha - Column C", "Total - Column D", "Table2.Nro TKt - Column A", "Table2.Cia - Column B", "Table2.Name - Column C", "Table2.Fecha - Column D", "Table2.Total - Column E"})
in
    #"Reordered Columns1"
with the result:

MatchDiffNro TKt - Column AName - Column BFecha - Column CTotal - Column DTable2.Nro TKt - Column ATable2.Cia - Column BTable2.Name - Column CTable2.Fecha - Column DTable2.Total - Column E
OK
0​
123456​
Juan
25/05/2018​
1500​
123456​
45​
Juan
25/05/2018​
1500​
OK
50​
123457​
Pablo
25/05/2018​
1800​
123457​
44​
Pablo
25/05/2018​
1750​
NO
4500​
0​
234566​
45​
Maria
26/05/2018​
-4500​
OK
300​
985285​
John
27/05/2018​
0​
985285​
230​
John
27/05/2018​
-300​
NO
-12500​
0​
123458​
55​
Carlos
25/05/2018​
12500​
NO
-135500​
0​
456789​
220​
Estela
26/05/2018​
135500​
NO
-5000​
234567​
Pedro
26/05/2018​
-5000​
0​
NO
-120​
985286​
MAteo
30/05/2018​
-120​
0​

<tbody>
</tbody>



<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,066
Messages
6,128,577
Members
449,459
Latest member
20rayallen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top