Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Finny388 - 11 Dec 2007 21:00 GMT
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
ilia - 11 Dec 2007 22:13 GMT
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 have a formula in B:B that looks like this
> =IF(ISERROR(MATCH(VLOOKUP(A1,I:J,2,FALSE),'$M:$M,0)),"Not Found","")
[quoted text clipped - 14 lines]
> Any help appreciated.
> thanks
ilia - 11 Dec 2007 22:14 GMT
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.

> Easiest way:
>
[quoted text clipped - 32 lines]
>
> - Show quoted text -
Finny388 - 17 Dec 2007 16:53 GMT
> 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
[quoted text clipped - 36 lines]
>
> > - Show quoted text -

Thanks Ilia works great
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.