Custom User Defined Function in place of Index(array(match(lookup,lookup array,0)) ?

Sense-A

New Member
Joined
Dec 17, 2009
Messages
43
I want to use a custom formula that only asks for the lookup value.

=INDEX('OrgKeys'!$E$2:$E$5000,MATCH(Lookup!$A8,'OrgKeys'!$A$2:$A$5000,0))

The only value that ever changes is the A8

So, for example, can I have a custom formula such as =orgkey(A8)

I would have to define 'OrgKeys'!$E$2:$E$5000 as the constant table that has the index values I want

I would also have to define 'OrgKeys'!$A$2:$A$5000 as always being the constant array I lookup the value in cell A8 in.

I'd like for the index table and array lookup table to be in a separate workbook on a specific drive in a specific directory that never changes.

It would be even cooler if you could type =orgkey() and by default it assumed you wanted to lookup the value in the cell to the left since that is 100% the case when I use the index(match) formula

Thanks!
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hello,

You could test the following UDF :

Code:
Function OrgKeys(rng As Range)
' example =OrgKeys(A8)
Dim res As Variant
res = Application.Match(rng, Sheets("OrgKeys").Range("A2:A5000"), 0)
  If IsError(res) Then
       OrgKeys = "N/A"
  Else
       OrgKeys = Application.Index(Sheets("OrgKeys").Range("E2:E5000"), res)
  End If
End Function

Hope this will help
 
Upvote 0
James006,

That works great! Thank you very much. I am going to impress the people in the budget office who will no longer need to look up funds, key descriptions, or account descriptions anymore!

Do you know how I can modify it so that it knows specifically which file (pathname) to look in? I'd like to keep the OrgKeys table in a separate workbook. Will it be able to lookup the data in an external workbook that is closed? Assuming it works like the index((match)) function, it should be able to.

Thanks.
 
Upvote 0
Glad to hear the UDF is helping you out ...

When it comes to a closed workbook ... am afraid it will not work ....

If you really need to deal with a closed workbook ... you will have to design a totally different approach ...
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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