Condense ISERROR(VLOOKUP(MATCH())) to VBA function.

F

Finny388

I have a formula in B:B that looks like this
=IF(ISERROR(MATCH(VLOOKUP(A1,I:J,2,FALSE),'$M:$M,0)),"Not Found","")

but
the VLOOKUP is standard. it always looks up adjacent cell in I and
returns J
VLOOKUP option always FALSE
MATCH option always 0

I think a VBA function could reduce it to this

=MYFIND(A1,$M:$M)

I know to store a function in a module in personal.xls but and I don't
know how to mimick these 3 formulas.

Any help appreciated.
thanks
 
I

ilia

Easiest way:

Public Function MyFind(myValue As Variant, myRange As Excel.Range) As
Variant
On Error Resume Next
With Application.WorksheetFunction
Call .Match(.VLookup(myValue, myRange.Parent.Range("$I:$J"), 2,
False), myRange, False)
End With
If Err.Number <> 0 Then
MyFind = "Not Found"
Else
MyFind = ""
End If
End Function
 
I

ilia

Note, however, that this function will not update if I:J changes
(because it's not in the argument list), so you have to recalc
manually.
 
F

Finny388

Note, however, that this function will not update if I:J changes
(because it's not in the argument list), so you have to recalc
manually.

Thanks Ilia works great
 

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