• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Have to compare two columns and highlight both the columns.

Rafay Ahmed

New Member
Hi All,
I tried to construct a macro to compare the two columns and highlight them. Any other good alternative would be appreciated.
Guidelines are also there in the attached sheet.
Thanks
 

Attachments

  • Chandoo File.xlsx
    22.6 KB · Views: 7
Hi !

At least share the code you tried to construct !

And if it's just to compare numbers on same row,
you do not ever need a code but just apply a conditional formatting …
 
I tried to record a macro, which did not worked, but yes you are right. I have matching numbers in different rows.
Attached is the document.
 

Attachments

  • Chandoo File.xlsx
    10.8 KB · Views: 8
So without any CF :​
Code:
Sub Demo1()
         Dim Rd As Range, Rc As Range, R&
     [A1].CurrentRegion.Columns("F:G").Interior.ColorIndex = xlNone
With Range([G1].End(xlDown), Cells(Rows.Count, 7).End(xlUp))
    For Each Rd In Range("F2", [F1].End(xlDown))
           Set Rc = .Find(Rd.Value, , xlValues, xlWhole)
        If Not Rc Is Nothing Then
                R = Rc.Row
            Do
               If Rc.Interior.ColorIndex = xlNone Then
                   Union(Rc, Rd).Interior.ColorIndex = 40
                   Exit Do
               Else
                   Set Rc = .FindNext(Rc)
               End If
            Loop Until Rc.Row = R
        End If
    Next
End With
           Set Rc = Nothing
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Back
Top