How do I compare 2 lists and show duplicates as a new list? PLEASEEEE

estezz

New Member
Joined
Jul 21, 2011
Messages
12
I have 2 lists of several part numbers, text and price { each row has 3 cells}. I need to compare both lists and extract all the duplicate ROWS, copy them and place them in a new list.
Does anyone have a macro that can do this task that they are willing to share?

Please help me, for advice on how to create macros and I'll be grateful, i need help TODAY :(
Maria from Czech republic :-*
estezz@seznam.cz
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Just some minor speed up of the code
Code:
Sub kpark91July21()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual
 
    Dim LR1&, LR2&, count&, dataWS1 As Worksheet, dataWS2 As Worksheet, i&, j&, destWS As Worksheet
    Set dataWS1 = ThisWorkbook.Worksheets("Sheet 1")
    Set dataWS2 = ThisWorkbook.Worksheets("Sheet 2")
    Set destWS = ThisWorkbook.Worksheets("Sheet 3")
    LR1 = dataWS1.Range("A" & Rows.count).End(xlUp).Row
    LR2 = dataWS2.Range("A" & Rows.count).End(xlUp).Row
    concatenateABC dataWS1, LR1, dataWS2, LR2
    count = 1
 
    For j = 1 To LR2
        For i = 1 To LR1
            If dataWS2.Range("D" & j).Value = dataWS1.Range("D" & i).Value Then
                dataWS2.Range("A" & j & ":C" & j).Copy destWS.Range("A" & count)
                count = count + 1
            End If
        Next i
    Next j
 
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
End Sub
Function concatenateABC(dataWS1 As Worksheet, LR1 As Long, dataWS2 As Worksheet, LR2 As Long)
    Dim i&
    For i = 1 To LR1
        dataWS1.Range("D" & i).Value = dataWS1.Range("A" & i).Value _
                                        & dataWS1.Range("B" & i).Value _
                                        & dataWS1.Range("C" & i).Value
    Next i
    For i = 1 To LR2
        dataWS2.Range("D" & i).Value = dataWS2.Range("A" & i).Value _
                                        & dataWS2.Range("B" & i).Value _
                                        & dataWS2.Range("C" & i).Value
    Next i
    Set dataWS1 = Nothing
    Set dataWS2 = Nothing
End Function
 
Upvote 0
subscript out of range wrote me...

You have to change your worksheet names
Code:
    Set dataWS1 = ThisWorkbook.Worksheets("Sheet 1")
    Set dataWS2 = ThisWorkbook.Worksheets("Sheet 2")
    Set destWS = ThisWorkbook.Worksheets("Sheet 3")

"Sheet 1" to your sheet1 name (Case-sensitive)
"Sheet 2" to your sheet2 name (Case-sensitive)
"Sheet 3" to your sheet3 name (Case-sensitive)
 
Upvote 0
Try the following:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Assuming your data is in Sheet01 and in the ranges:<o:p></o:p>
<o:p></o:p>
List1 - A1:C7<o:p></o:p>
<o:p></o:p>
List2 - E1:G7<o:p></o:p>
<o:p></o:p>
Then do the following (for 2007):<o:p></o:p>
<o:p></o:p>
Click in Data tab, and, in the group Filter and Sort, click in Advanced.<o:p></o:p>
Then, type the following (in the indicated fields on the dialog box Advanced Filter):<o:p></o:p>
<o:p></o:p>
List range: A1:C7 <o:p></o:p>
Criteria range: E1:G7 <o:p></o:p>
Copy to: I1<o:p></o:p>
<o:p></o:p>
And mark the Select Box Copy to another local. <o:p></o:p>
<o:p></o:p>
Finally, click OK.

<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td><td style="text-align: right;;"></td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td><td style="text-align: right;;"></td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td><td style="font-weight: bold;color: #FF0000;;">Data Filtered</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">158</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">108</td><td style=";">mdartin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">178</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">198</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">148</td><td style=";">pavel</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">1778</td><td style=";">sad</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet01</p><br /><br />
Markmzz<o:p></o:p>
 
Upvote 0
to Markmzz:
It is good, but I need to duplicate the results on a new sheet, the original data are on sheet 1 and the new sheet 2 can not be on the same sheet
 
Upvote 0
to Markmzz:
It is good, but I need to duplicate the results on a new sheet, the original data are on sheet 1 and the new sheet 2 can not be on the same sheet

Try the following:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Assuming your data is in Sheet01 and in the ranges:<o:p></o:p>
<o:p></o:p>
List1 - A1:C7<o:p></o:p>
<o:p></o:p>
List2 - E1:G7<o:p></o:p>
<o:p></o:p>
And new data (List3) will be in the Sheet02.

Then do the following (for 2007):<o:p></o:p>
<o:p></o:p>
With Sheet02 activated.

Click in Data tab, and, in the group Filter and Sort, click in Advanced.<o:p></o:p>
Then, type the following (in the indicated fields on the dialog box Advanced Filter):<o:p></o:p>
<o:p></o:p>
List range: Sheet01!A1:C7 <o:p></o:p>
Criteria range: Sheet01!E1:G7 <o:p></o:p>
Copy to: Sheet02!I1<o:p></o:p>
<o:p></o:p>
And mark the Select Box Copy to another local. <o:p></o:p>
<o:p></o:p>
Finally, click OK.
 
Upvote 0
I use a macro where you have to copy it? alt + f11 and some sheet or workbook?
where should I have the cursor when it spostim and must have something to sign?
 
Upvote 0
Estezz,

Did carefully followed the steps in my post?

Look at this:

<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td><td style="text-align: right;;"></td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">158</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">108</td><td style=";">mdartin</td><td style="text-align: right;;">7/20/2010</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">178</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">198</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">148</td><td style=";">pavel</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">1778</td><td style=";">sad</td><td style="text-align: right;;">7/20/2010</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td></tr></tbody></table><p style="width:4.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet01</p><br /><br /><b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;"></td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;;">Col03</td><td style="font-weight: bold;color: #FF0000;;">Data Filtered</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;"></td><td style="text-align: right;;">199</td><td style=";">jan</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;">148</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;">718</td><td style=";">martin</td><td style="text-align: right;;">7/20/2010</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet02</p><br /><br />
If Yes, then tell me the sheets and ranges of your data.


Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
rootytrip

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