Results 1 to 11 of 11

Comparing columns and highlighting differences

Threaded View

Sejrup Comparing columns and... 09-01-2010, 06:20 AM
StephenR Re: Comparing columns and... 09-01-2010, 06:55 AM
Sejrup Re: Comparing columns and... 09-01-2010, 07:00 AM
snb Re: Comparing columns and... 09-01-2010, 07:06 AM
venkat1926 Re: Comparing columns and... 09-01-2010, 07:05 AM
StephenR Re: Comparing columns and... 09-01-2010, 07:09 AM
Sejrup Re: Comparing columns and... 09-01-2010, 08:47 AM
StephenR Re: Comparing columns and... 09-01-2010, 08:58 AM
Sejrup Re: Comparing columns and... 09-01-2010, 09:15 AM
snb Re: Comparing columns and... 09-01-2010, 09:18 AM
Sejrup Re: Comparing columns and... 09-01-2010, 09:24 AM
  1. #9
    Registered User
    Join Date
    08-11-2010
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Comparing columns and highlighting differences

    The first solution compares one line at a time so using the macro on the new example file it stops working if there are more entries in the one data set as far as I can tell.

    Second solution offered adds one color to row 2 and another color to the remaining rows containing data.

    What I have tried so far is to concatenate the value of the two columns in each set, write these to two new ranges in the sheet and then do a comparison of these new colums using the following code:

    Private Sub MarkAllUnfoundCells(r1 As Range, r2 As Range)
        Dim c As Range
        For Each c In r1.Cells
            If Not IsInRange(r2, c.Value) Then
                c.Interior.ColorIndex = 3
            End If
        Next
    End Sub
    
    Private Function IsInRange(r As Range, target As String) As Boolean
        Dim c As Range
        For Each c In r.Cells
            If c.Value = target Then
                IsInRange = True
                Exit Function
            End If
        Next
        IsInRange = False
    End Function
    Just passing on the two new ranges to the private sub that uses the function IsInRange.
    The problem with this approach is speed. Comparing two ranges with approximately 10,000 rows or more takes a lot of time. First writing the two new columns and afterwards comparing the value of a single cell with each cell in the second range.

    Doing this also only paints one color if there is a mismatch and it does so in the new columns created.
    Last edited by Sejrup; 09-01-2010 at 09:25 AM.

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