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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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