+ Reply to Thread
Results 1 to 5 of 5

Comparing two sets of data

Hybrid View

  1. #1
    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

  2. #2
    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