Closed Thread
Results 1 to 5 of 5

How to compare data between 2 worksheets and display the differences

  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    26

    How to compare data between 2 worksheets and display the differences

    I need the help of experts.

    I have attached the sample and hope to receive help urgently. 30042012.zip

    basically, I need to find the ID that is not in D1, but is present in D. so i.e.(ID 12345 in D but not present in D1), then display that ID number.

    I am thinking of using MATCH and INDEX, but anything would do as long as it works. Hope that clarifies my needs, thank you and need help badly.

    regards,
    Melvyn

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: How to compare data between 2 worksheets and display the differences

    Hi

    Id in D is not in D1 then where should that row be displayed?
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: How to compare data between 2 worksheets and display the differences

    Hi

    Try this. Hope this will help you...

    30042012.xls

    This is the code:
    Sub findmatch()
    Dim rd As Long, rd1 As Long, finalcnt As Long

    rd = Sheets("D").Range("A" & Rows.Count).End(xlUp).Row
    rd1 = Sheets("D1").Range("A" & Rows.Count).End(xlUp).Row
    finalcnt = Sheets("Difference").Range("A" & Rows.Count).End(xlUp).Row

    For i = 2 To rd
    For j = i To rd1
    If Sheets("D").Range("A" & i).Value <> Sheets("D1").Range("A" & j).Value Then
    finalcnt = finalcnt + 1
    Sheets("Difference").Range("A" & finalcnt).Value = Sheets("D").Range("A" & i).Value
    Else
    Exit For
    End If
    Next
    If j > rd1 Then
    finalcnt = finalcnt + 1
    Sheets("Difference").Range("A" & finalcnt).Value = Sheets("D").Range("A" & i).Value
    End If
    Next
    End Sub

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to compare data between 2 worksheets and display the differences

    Raj,

    Please use code tags.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to compare data between 2 worksheets and display the differences

    Also,

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1