Results 1 to 11 of 11

Comparing columns and highlighting differences

Threaded View

  1. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Comparing columns and highlighting differences

    Read all suggestions in this thread
    Avoid using merged cells.
    I deleted the first row for that reason.
    And applied this macro:
    Sub snb()
      sq = Cells(1, 1).CurrentRegion
      sn = Cells(1, 5).CurrentRegion
      For j = 2 To UBound(sq)
        For jj = 2 To UBound(sn)
          If sq(j, 2) = sn(jj, 3) Then
            Cells(jj, 5).Resize(, 5).Interior.ColorIndex = IIf(sq(j, 3) = sn(jj, 4), 12, 10)
            Cells(j, 1).Resize(, 3).Interior.ColorIndex = IIf(sq(j, 3) = sn(jj, 4), 12, 10)
            Exit For
          End If
        Next
      Next
    End Sub
    an alternative:

    Sub tst2()
      On Error Resume Next
      sq = Cells(1, 1).CurrentRegion
      For j = 2 To UBound(sq)
        With Columns(7).Find(sq(j, 2)).Offset
          If Err.Number = 0 Then
            .Offset(, -2).Resize(, 5).Interior.ColorIndex = IIf(.Offset(, 1) = sq(j, 3), 14, 16)
            Cells(j, 1).Resize(, 3).Interior.ColorIndex = IIf(.Offset(, 1) = sq(j, 3), 14, 16)
          End If
          Err.Clear
        End With
      Next
    End Sub
    Last edited by snb; 09-01-2010 at 09:37 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