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.
I sent you an email with workbook attached named Book1
from my spambox email :D

For future curious people,
Code:
Sub kpark91July21()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual
    
    Dim LR1&, LR2&, count&, i&, j&
    LR1 = Worksheets("Sheet1").Range("A" & Rows.count).End(xlUp).Row
    LR2 = Worksheets("Sheet2").Range("A" & Rows.count).End(xlUp).Row
    count = 1
    
    For i = 1 To LR1
        Worksheets("Sheet1").Range("D" & i).Value = Worksheets("Sheet1").Range("A" & i).Value _
                                        & Worksheets("Sheet1").Range("B" & i).Value _
                                        & Worksheets("Sheet1").Range("C" & i).Value
    Next i
    For i = 1 To LR2
        Worksheets("Sheet2").Range("D" & i).Value = Worksheets("Sheet2").Range("A" & i).Value _
                                        & Worksheets("Sheet2").Range("B" & i).Value _
                                        & Worksheets("Sheet2").Range("C" & i).Value
    Next i
    
    
    
    For j = 1 To LR2
        For i = 1 To LR1
            If Worksheets("Sheet2").Range("D" & j).Value = Worksheets("Sheet1").Range("D" & i).Value Then
                Worksheets("Sheet2").Range("A" & j & ":C" & j).Copy Worksheets("Sheet3").Range("A" & count)
                count = count + 1
            End If
        Next i
    Next j
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
End Sub

Useless coding.. I know..
 
Upvote 0
Lets try again.

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:

List1 - Sheet01 - range - A1:C7<o:p></o:p>
<o:p></o:p>
List2 - Sheet02 - range - E1:G7<o:p></o:p>
<o:p></o:p>
And that new data (List3 - the data duplicate) will be in the Sheet03.

Then do the following:<o:p></o:p>
<o:p></o:p>
Important: with Sheet03 Selected.

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>

Mark the Select Box Copy to another local.

<o:p></o:p>
List range: Sheet01!A1:C7 <o:p></o:p>
Criteria range: Sheet02!E1:G7 <o:p></o:p>
Copy to: Sheet03!I1

Finally, click OK. <!-- / message -->
 
Upvote 0
yes, its ok, your metod is function. thank you
BUT KPARK91 is Geunius, He did exactly what I needed

Lets try again.

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:

List1 - Sheet01 - range - A1:C7<o:p></o:p>
<o:p></o:p>
List2 - Sheet02 - range - E1:G7<o:p></o:p>
<o:p></o:p>
And that new data (List3 - the data duplicate) will be in the Sheet03.

Then do the following:<o:p></o:p>
<o:p></o:p>
Important: with Sheet03 Selected.

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>

Mark the Select Box Copy to another local.

<o:p></o:p>
List range: Sheet01!A1:C7 <o:p></o:p>
Criteria range: Sheet02!E1:G7 <o:p></o:p>
Copy to: Sheet03!I1

Finally, click OK. <!-- / message -->
 
Upvote 0
hi Kpark,

This really helped me, but I want the same with different workbooks. I have two different workboooks with 15 columns and 50k rows in one workbook and 10columns and 1000 rows in another workbook and only 1 column(partnumber) in common. So i want to pull two reports from this.

1. common partnumbered rows in to a different workbook as one report
2. I want to delete the common part numbered rows from first workbook and copy into a different workbook as another report.

Could you please help me with this as i am a new to Excel.

Thanks,
Angiee



I sent you an email with workbook attached named Book1
from my spambox email :D

For future curious people,
Code:
Sub kpark91July21()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual
 
    Dim LR1&, LR2&, count&, i&, j&
    LR1 = Worksheets("Sheet1").Range("A" & Rows.count).End(xlUp).Row
    LR2 = Worksheets("Sheet2").Range("A" & Rows.count).End(xlUp).Row
    count = 1
 
    For i = 1 To LR1
        Worksheets("Sheet1").Range("D" & i).Value = Worksheets("Sheet1").Range("A" & i).Value _
                                        & Worksheets("Sheet1").Range("B" & i).Value _
                                        & Worksheets("Sheet1").Range("C" & i).Value
    Next i
    For i = 1 To LR2
        Worksheets("Sheet2").Range("D" & i).Value = Worksheets("Sheet2").Range("A" & i).Value _
                                        & Worksheets("Sheet2").Range("B" & i).Value _
                                        & Worksheets("Sheet2").Range("C" & i).Value
    Next i
 
 
 
    For j = 1 To LR2
        For i = 1 To LR1
            If Worksheets("Sheet2").Range("D" & j).Value = Worksheets("Sheet1").Range("D" & i).Value Then
                Worksheets("Sheet2").Range("A" & j & ":C" & j).Copy Worksheets("Sheet3").Range("A" & count)
                count = count + 1
            End If
        Next i
    Next j
 
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
End Sub

Useless coding.. I know..
 
Upvote 0

Forum statistics

Threads
1,224,588
Messages
6,179,743
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