You are here:

Excel/Custom Function for V_Lookup


Hi Jerry,

I was trying to make a custom function which can mimic vlookup. but I couldnot get this working. Please help me with this.
I have put this code in Personal.xlsb :

What i am trying is to employ Match and index functions to mimic Vlookup, but its not working.
Function DLookup(LookupRange As Range, FindValue As String, RowRange As Range, ColNum As Integer)

Dim Result As Variant
Result = Application.WorksheetFunction.Index(LookupRange, Application.WorksheetFunction.Match(FindValue, RowRange, 0), ColNum)

End Function

This is giving me zero as the result.

Like so:

Function DLookup(LookupTable As Range, FindValue As String, LookupRange As Range, ReturnCol As Long)

DLookup = Application.WorksheetFunction.Index(LookupTable, Application.WorksheetFunction.Match(FindValue, LookupRange, 0), ReturnCol)

End Function

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Jerry Beaucaire


Excel Formulas, macros, automation. Microsoft Excel MVP - 2010. Code site with free code snippets and techniques:


Microsoft Excel MVP - 2010. I have my own extensive Excel help/code site: ===================== I have been offering free assistance as an Excel aid on many web sites for many years: ( - JBeaucaire) ======== ( - JBeaucaire) ======= ( - jbeaucaire)

Bachelor's Degree from Azusa Pacific University in Mathematics and Music Composition

Awards and Honors
Microsoft Excel MVP 2010

©2016 All rights reserved.