Getting the difference between to sheets

Richardabichahla

Registered User.
Local time
Tomorrow, 00:27
Joined
Jun 7, 2010
Messages
18
Hello Guys,

I have two excel sheets, sheet A with 8000 entries and another sheet B with 3000.
the entries of sheet B are all available in Sheet A.

What i need is a sheet C that contains the 5000 entries that are in Sheet A and not in sheet B ( what i call the difference or the result , A-B = C ).

Is their a tool in excel or an external tool that i can use to perform this action ?
 
I presume that there is a column in each worksheet with a unique code that you are going to compare? Are the sheets sorted in any order?

Brian
 
no there is no unique code but we can sort them by names.
 
I think this will do what you want after you have altered it to suit your workbook. No sorting required.

Brian

Code:
Sub copyrows()

'This copies rows from sheet1 without a match in sheet2 to sheet3
'It assumes that the data starts in row3 in each sheet and that the match column is B
' Headings have not been copied

Dim lastrow1 As Long
Dim lastrow2 As Long
Dim rownum1 As Long
Dim rownum2 As Long
Dim rowindex As Long

lastrow1 = Sheets("sheet1").Range("A65536").End(xlUp).Row  
lastrow2 = Sheets("sheet2").Range("A65536").End(xlUp).Row   

rownum1 = 3
rowindex = 3    'for sheet3
Do
    rownum2 = 3
    Do Until rownum2 > lastrow2
        If Sheets("sheet1").Cells(rownum1, 2) = Sheets("sheet2").Cells(rownum2, 2) Then
    Exit Do
        Else
         rownum2 = rownum2 + 1
        End If
    Loop
If rownum2 > lastrow2 Then
Sheets("sheet1").Rows(rownum1).Copy
       Worksheets("Sheet3").Cells(rowindex, 1).PasteSpecial
       rowindex = rowindex + 1
End If
rownum1 = rownum1 + 1
Loop Until rownum1 > lastrow1

Application.CutCopyMode = False

End Sub
 
Sorry man for my late reply... I didn t try your way because i am not a good programmer !!
what i was asking for is if there is a plugin or a software that i can buy or download for excel that will do this job.

thank you for your tip.
 

Users who are viewing this thread

Back
Top Bottom