Replace #VALUE with 0

  • Thread starter Thread starter Lok Tak Cheong
  • Start date Start date
L

Lok Tak Cheong

I have set a formula as below, attempt to replace #VALUE for error with 0,
but it does not work, anyone can give me some hints?

Function evlookup(A, B, C)
D = WorksheetFunction.VLookup(A, B, C, False)
If WorksheetFunction.IsNA(D) = True Then
evlookup = 0
Else
evlookup = D
End If
End Function
 
Function evlookup(A, B, C)
On Error Resume Next
d = WorksheetFunction.VLookup(A, B, C, False)
On Error GoTo 0

If IsEmpty(d) Then
evlookup = 0
Else
evlookup = d
End If
End Function




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Your call to VLookup generates an error and execution bumbs out of your
function.

Try this:

Function evlookup(A, B, C)
On Error Resume Next
evlookup = 0
evlookup = WorksheetFunction.VLookup(A, B, C, False)
On Error GoTo 0
End Function
 
Dear Bob & PapaDos:
Thanks a lot!

PapaDos said:
Your call to VLookup generates an error and execution bumbs out of your
function.

Try this:

Function evlookup(A, B, C)
On Error Resume Next
evlookup = 0
evlookup = WorksheetFunction.VLookup(A, B, C, False)
On Error GoTo 0
End Function
 
Back
Top