Hi All, hoping to get some advice / help.
In short, I have a workbook with a lot of data
Sheet 1 contains around 300,000 rows and 6 columns . In sheet 1, I am using column A and B as my lookup key. Basically if lookup using column A is returning and error then use the lookup key in column B, and if still returning an error then populate "Check"
Sheet 2 contains around 150,000 rows and 98 columns. In sheet 2, column 99, I am performing the lookup process.
What I have right now is a For Loop, to illustrate
I normally get away with this because my data set is relatively small, but this time around while it works and give the result that I need, it is taking forever to run (I think it is over an hour)
Is there a better way to do this? I have not had much experience with VBA
Thanks!
In short, I have a workbook with a lot of data
Sheet 1 contains around 300,000 rows and 6 columns . In sheet 1, I am using column A and B as my lookup key. Basically if lookup using column A is returning and error then use the lookup key in column B, and if still returning an error then populate "Check"
Sheet 2 contains around 150,000 rows and 98 columns. In sheet 2, column 99, I am performing the lookup process.
What I have right now is a For Loop, to illustrate
VBA Code:
For i = 1 to Sheet 2 Last Row
Result_1 = application.index(rngResult, application.match(sheet2.cells(i,1).value, rngSourceColumnAsheet1,0),1)
Result_2 = application.index(rngResult, application.match(sheet2.cells(i,1).value, rngSourceColumnBsheet,0),1)
if iserror(Result_1) then
ResultFinal = Result_2
if iserror(Result_2) then
ResultFinal = "Check"
end if
else
ResultFinal = Result_1
end if
sheet2.cells(i,98).value = ResultFinal
next i
I normally get away with this because my data set is relatively small, but this time around while it works and give the result that I need, it is taking forever to run (I think it is over an hour)
Is there a better way to do this? I have not had much experience with VBA
Thanks!