Matching 5 is easy and fast
This seems to work on my test data
Also assumes that there can be multiple K values for each G value
Option Explicit Sub match_5() Dim rG As Range, rK As Range Dim G As Long, K As Long, n As Long Application.ScreenUpdating = False 'setup G's Set rG = ActiveSheet.Cells(1, 7) Set rG = Range(rG, rG.End(xlDown)) rG.Interior.ColorIndex = xlColorIndexNone 'setup K's Set rK = ActiveSheet.Cells(1, 11) Set rK = Range(rK, rK.End(xlDown)) rK.Interior.ColorIndex = xlColorIndexNone For G = 1 To rG.Rows.Count If G Mod 100 = 0 Then Application.StatusBar = "Processing G row " & Format(G, "#,##0") Set rK = ActiveSheet.Cells(1, 11) Set rK = Range(rK, rK.End(xlDown)) n = 0 On Error Resume Next n = Application.WorksheetFunction.Match(rG.Cells(G, 1), rK, 0) Do While n > 0 rG.Cells(G, 1).Interior.Color = vbRed rK.Cells(n, 1).Interior.Color = vbRed Set rK = rK.Cells(n + 1, 1) Set rK = Range(rK, rK.End(xlDown)) n = 0 n = Application.WorksheetFunction.Match(rG.Cells(G, 1), rK, 0) Loop On Error GoTo 0 Next G Application.StatusBar = False Application.ScreenUpdating = True End Sub




Reply With Quote