HI,

I am trying to write a custom function to replace vlookups. Problem is it only returns the value 0 in a cell.

When I recreated this as a sub rather than a function it works perfectly. I am prob missing something small but it is driving me insane.

Thanks for any assistance


Function DLookup(LookUpValue As String, Lookup_Range As Range, Displacement_From_Range As String)

Lookup_Range.Select

Selection.Find(What:=LookUpValue, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

DLookup = ActiveCell.Offset(0, Displacement_From_Range).Value

End Function