Hi
I was looking at a closed thread called:
Explain =LOOKUP(2,1/(A2:A10=D2),B2:B10)
I thought I'd add some information from a bit of research I've done.
I'm using Excel 2003. I've tried later versions but prefer to continue with this one.
I use the MATCH() worksheet function a lot, often combined with INDEX(), and for various projects I found I needed a similar function to match the last instance of a value rather than the first.
Initially, I wrote a small and fairly simple UDF which I called RevMATCH() and this worked pretty well. Code as follows:
But I want to avoid UDFs wherever possible, since they tend to operate very slowly compared to worksheet functions. Also they make your workbooks less portable.
So, with this in mind, I thought that one solution might be to create a reversed range somewhere on the sheet in question and then just use MATCH() on it. The "upside-down" range can then be hidden away.
This worked OK but became a bit cumbersome when the ranges being worked upon were large.
I found two other solutions, one using MATCH() and MAX() in an array formula, but I'm not a big fan of array formulas. Another uses MATCH() and SUMPRODUCT(). Both of these worked OK but ended up with very long multi-line formulas.
Finally (perhaps) I found this thread, and using LOOKUP() with vectors seems to solve the problem. The formula is still quite long but is a bit shorter than the others.
I've attached a little workbook that tests all these solutions. It is, I think, self explanatory. I hope I've managed to attach it properly.
Can anyone think of any better solution?
Alan
Bookmarks