Help with Custom Function

F

Flamikey

Hi,
I know very little about VBA....I am trying to create a user define
function. I use the following formula all the time and wanted to sav
it as a function to save time....
=IF(ISERROR(VLOOKUP(LOOKUP_VALUE,TABLE_ARRAY,COL_INDEX_NUM,RANGE_LOOKUP),0,VLOOKUP(LOOKUP_VALUE,TABLE_ARRAY,COL_INDEX_NUM,RANGE_LOOKUP)

I inserted a new module in VBA to create the function and worte th
following( I am sure I am way off)......

Function Noerorvlookup(Lookup, Range, Column)
Noerrorvlookup
IF(ISERROR(VLOOKUP,Lookup,Range,Column,False),0,VLOOKUP,Lookup,Range,Column,False))
End Function

Can anyone help fix my horrible code?

Thanks!
 
T

Tom Ogilvy

Function Noerorvlookup(Lookup As Variant, Rng As Range, Col As Long)
Dim res as Variant
res = Application.VLookup(Lookup, Rng, Col, False)
If IsError(res) Then
Noerorvlookup = 0
Else
Noerorvlookup = res
End If
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top