Optimize Index Lookup Formula?

JPARKHURST

Board Regular
Joined
Oct 25, 2016
Messages
151
I have a formula which works, but I would like to see if it's as optimized as it could be. I've a new computer and it's either a LOT slower than my older one (very possible), or this forumla needs to be optimized with a better formula or moved to VBA.

I am looking for the last instance of a parts shortage, which are complied in a different worksheet (same job listed concatenates multiple shortages for one display on the last shortage).

Code:
=IFERROR(INDEX(Shortages!$N:$N,LOOKUP(2,1/(Shortages!$B:$B=D2),ROW(Shortages!$B:$B))),"")

Thanks in advance,

Jon
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
First, you can rewrite that a bit more concisely as:

Code:
=IFERROR(LOOKUP(2,1/(Shortages!$B:$B=D2),Shortages!$N:$N),"")

but that probably won't speed it up much. The biggest change you can do would be to avoid whole column references, like this:

Code:
=IFERROR(LOOKUP(2,1/(Shortages![COLOR=#ff0000]$B1:$B100[/COLOR]=D2),Shortages![COLOR=#ff0000]$N1:$N100)[/COLOR],"")
Figure out the maximum row you expect to use and use that, otherwise, Excel is forced to examine over a million rows, even if you only use 100.
 
Upvote 0
Good catch. I found an error this morning (was only looking for first row, when I had changed my source sheet a week ago). Completely missed the forest for the trees on that one.

Thanks again!

Jon

Oh, yeah, that definitely made all the difference in the world. Thanks again for finding my mistake!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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