ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Emulate Index/Match combo function w/ VBA custom function (https://www.excelbanter.com/excel-worksheet-functions/24456-emulate-index-match-combo-function-w-vba-custom-function.html)

Spencer Hutton

Emulate Index/Match combo function w/ VBA custom function
 
Does anyone know the code to emulate this function using a custom VBA function:

=INDEX(ReturnRange(MATCH(MatchValue,LookupRange,0) )

TIA.

Bernie Deitrick

Spencer,

For example:

Dim ReturnRange As Range
Dim MatchValue As Variant
Dim LookupRange As Range

Set ReturnRange = Range("A1:A10")
MatchValue = 17
Set LookupRange = Range("B1:B10")

MsgBox Application.Index(ReturnRange, _
Application.Match(MatchValue, LookupRange, 0)).Value

HTH,
Bernie
MS Excel MVP


"Spencer Hutton" wrote in message
...
Does anyone know the code to emulate this function using a custom VBA

function:

=INDEX(ReturnRange(MATCH(MatchValue,LookupRange,0) )

TIA.




Niek Otten

Maybe the discussion a few lines below this one (Sumif - FastExcel, poster
Naz) is interesting for you

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel


"Spencer Hutton" wrote in message
...
Does anyone know the code to emulate this function using a custom VBA
function:

=INDEX(ReturnRange(MATCH(MatchValue,LookupRange,0) )

TIA.





All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com