I have got an excel spreadsheet (sheet2) with records of count around 1 Million. I am iterating these records and for each iteration I am comparing a row of selected columns against another range of around 2000 records which is in sheet1.
rangeA = 1 Million rows 'Sheet2
rangeB = 2000 rows 'Sheet1
With sheet1
For Each row In rangeA.Columns.Rows
For Each rangeBRow In rangeB.Columns.Rows
If (.Cells(rangeBRow.Row,1).Value = CName And .Cells(rangeBRow.Row,2).Value = LBL ... ) Then
' Do something cool... set some cell value in sheet2
Exit For
End If
Next rangeBRow
Next row
End With
My problem with the above code is that it is taking forever to complete the execution. Is there some other fastest and a quick way to find a row against a range of rows in excel macro other than iterating a million records for 2000 rows?
Thank you for your time.
12 seconds to check 5k rows against 200k: