+ Reply to Thread
Results 1 to 5 of 5

Comparing two sets of data

Hybrid View

  1. #1
    Registered User
    Join Date
    11-09-2011
    Location
    bombay
    MS-Off Ver
    Excel 2003
    Posts
    10

    Comparing two sets of data

    Hi

    I need help with comparing two sets of data.

    ip.jpg [in attachment]

    Basically, I need to compare Table 1 and Table 2 and indicate the cells that do not match in RED colour.

    Something like this:

    op.jpg [in attachment]

    As you see, column 1 is unavailable in Table2. So that is marked red completely. Similarly for col 5 and 7 in table 2. So is the case with Beta (in table 1) and Epsilon in Table 2.

    Please help me with this.
    Attached Images Attached Images

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Comparing two sets of data

    Hello indimonk,

    While pictures serve as a nice informational reference, they are not helpful in getting you an answer. Members are not likely to take the time to recreate what you have already done. It takes you no more time to post your workbook than the pictures. Help yourself and post your workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-09-2011
    Location
    bombay
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Comparing two sets of data

    I have attached the workbook for your reference.

    Please help.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    11-04-2011
    Location
    pak
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Comparing two sets of data

    Hello
    I have done a code for you. rest you can do it by yourself.I have used loops, perhaps someone have much easier thing to do. secondly, your tables are not of same diemnsion, the last col of table 2 will always be different. this code only colors table 1 items , for table 2 you can opy code and modify the variables

    Option Explicit
     Sub remove_duplicate()
     Application.ScreenUpdating = False
     Dim arr1() As Variant
     Dim comarr() As Variant
     Dim list1 As Variant
     Dim complist As Variant
     Dim TheRange As Range
     Dim i, j, k, l, m, n, o, p, q, r, s As Long
     Dim upper As Long
     Dim StartTime As Double
      
     
     
     
    ReDim arr1(17 To 21, 4 To 8)
    ReDim comarr(17 To 21, 11 To 16)
    
    
     
     For j = 17 To 21
        For k = 4 To 8
            arr1(j, k) = Cells(j, k).Value
            
            
        Next
     Next
     
      
     For j = 17 To 21
        For k = 11 To 16
            comarr(j, k) = Cells(j, k).Value
           
        Next
     Next
     
     r = 5
     s = 12
     
     For l = 18 To 21
     
            If arr1(l, 4) <> comarr(l, 11) Then
                      
                         Range(Cells(l, 4), Cells(l, 8)).Select
                            With Selection.Interior
                            .Pattern = xlSolid
                            .PatternColorIndex = xlAutomatic
                            .Color = 255
                            .TintAndShade = 0
                            .PatternTintAndShade = 0
                            End With
            Else
             
             For q = 18 To 21
             
                For m = r To 8
                        
                   For n = s To 15
                   
                        If arr1(q, m) <> comarr(q, n) Then
                        
                           Cells(q, m).Select
                            With Selection.Interior
                            .Pattern = xlSolid
                            .PatternColorIndex = xlAutomatic
                            .Color = 255
                            .TintAndShade = 0
                            .PatternTintAndShade = 0
                            End With
                           r = r + 1
                           s = s + 1
                    Exit For
                            
                    Else
                      
                            r = r + 1
                            s = s + 1
                    Exit For
                    End If
                      
                    Next
            Next
        Next
            
    End If
        
    Next
                                      
               
                         
                
     End Sub

  5. #5
    Registered User
    Join Date
    11-09-2011
    Location
    bombay
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Comparing two sets of data

    Hi Shaukat

    I was stuck with the coding even though I had the logic ready. Your code did give me an idea of how to proceed. Working on it now. Will keep you posted about the progress.

    Anyway thank you so much for taking the pains.

+ Reply to 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