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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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