Quicker way than this to lookup 2 criteria ? Very slow

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
when running this code to lookup criteria on just about 300 rows, excel hangs and this takes maybe 30 seconds

Code:
=LOOKUP(2,1/((A9=Sheet1!A:A)*($E$1=Sheet1!E:E)),Sheet1!C:C)

its to output value in Sheet1 column C where the 2 criteria match

any quicker way, sure there will be
thanks in advance
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
try limiting the range you are searching to only the used range of the column and not the entire column
 
Upvote 0
Thanks i will try it

Though the range is about 30000 rows, not sure if it will help
 
Upvote 0
I think you can limit the calculations with if statements...

IF(A9=Sheet1!A:A,$E$1=Sheet1!E:E)

Im not sure though, maybe that will error but the idea is to only do the caluclation for E1=Sheet1!E(x) ... if the first test is true... your way now always does every comparison. So even if the first test is false, it will still do the 2nd test for every row

But i think regardless you need to do a ton of calculations, I would be interested to see if someone comes up with an efficient way. There probably is a better way. If you do it in VBA you can structure the code in a way to minimize the calculations
 
Last edited:
Upvote 0
I think you can limit the calculations with if statements...

IF(A9=Sheet1!A:A,$E$1=Sheet1!E:E)

Im not sure though, maybe that will error but the idea is to only do the caluclation for E1=Sheet1!E(x) ... if the first test is true... your way now always does every comparison. So even if the first test is false, it will still do the 2nd test for every row

But i think regardless you need to do a ton of calculations, I would be interested to see if someone comes up with an efficient way. There probably is a better way. If you do it in VBA you can structure the code in a way to minimize the calculations

thanks, your first suggestion is much better

now takes around 5 seconds

Code:
=LOOKUP(2,1/((A9=Sheet1!A2:A30000)*($E$1=Sheet1!E2:E30000)),Sheet1!C2:C30000)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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