In VBA, I'd use:
Dim res as variant 'it could be an error
dim myVal as long 'double, string ????
dim LookUpRng as range
set lookuprng = worksheets("Sheet2").range("a:b")
myval = 21234
res = application.vlookup(myval, lookuprng, 2, false)
if iserror(res) then
msgbox "not found" 'like #n/a error
else
msgbox res
end if
Tenerife Alan wrote:
I am using Excel 2003 and Visual Basic 6.3
VLOOKUP works fine in a worksheet but I am having trouble when I try to
invoke it in VB.
My code is
head = VLookup(code, "\icodes", 2)
Where code is a VB variable and "\icodes" is a named range on a worksheet.
I get the error message Function not defined.
--
Tenerife Alan
--
Dave Peterson