Finding Matching Numbers From Last Row Up

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Code:
'********** Step Through Rows Backwards *****************
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For myrow = lastrow To 6 Step -1
    Columns("B:C").Select
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
        With Selection.FormatConditions(1).Font
            .Color = 0
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 13551615
            .TintAndShade = 0
        End With
    Selection.FormatConditions(1).StopIfTrue = False
Next myrow

Hello All.
I'm attempting to find matching numbers and highlight them in columns B&C. The code above I used the recorder, which is working, but does not seem like an efficient way. I feel if the numbers in column C extended a long way down, the code would take a long time to run, It appears this way, the program is running one line at a time, finds a matching number, and then starts all the way down at the bottom again to find another set of matching numbers.
Is there a better way to do this?
Thanks for the help
 
How about
Code:
Sub GetMatch()

   Dim Cl As Range
   
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         If Not IsError(Application.Match(Cl.Value, Columns(2), 0)) Then Cl.EntireRow.Interior.Color = vbRed
      Next Cl

End Sub
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Holy Cow!
It Works!
Thank you very much...

Also, before I replied, I spent some time looking at this code. If I read this correctly, the code is looking at the end of Column C & working it's way up to the top. At the same time, it's finding a match value between Column C to Column (2,0) which is Column B, one row at a time, and then highlighting the row if the condition of match is true....I think
 
Upvote 0
Glad to help & thanks for the feedback.

The code actually starts in C2 & works down, but otherwise, yes.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top