PC Review


Reply
Thread Tools Rate Thread

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

 
 
Finny388
Guest
Posts: n/a
 
      11th Dec 2007
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
 
Reply With Quote
 
 
 
 
ilia
Guest
Posts: n/a
 
      11th Dec 2007
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


On Dec 11, 4:00 pm, Finny388 <finny...@yahoo.com> wrote:
> 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


 
Reply With Quote
 
ilia
Guest
Posts: n/a
 
      11th Dec 2007
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.


On Dec 11, 5:13 pm, ilia <iasaf...@gmail.com> wrote:
> 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
>
> On Dec 11, 4:00 pm, Finny388 <finny...@yahoo.com> wrote:
>
>
>
> > 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- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
Finny388
Guest
Posts: n/a
 
      17th Dec 2007
On Dec 11, 4:14 pm, ilia <iasaf...@gmail.com> wrote:
> 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.
>
> On Dec 11, 5:13 pm, ilia <iasaf...@gmail.com> wrote:
>
> > 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

>
> > On Dec 11, 4:00 pm, Finny388 <finny...@yahoo.com> wrote:

>
> > > 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- Hide quoted text -

>
> > - Show quoted text -


Thanks Ilia works great
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IsError and Match function =?Utf-8?B?R0RDcm9zcw==?= Microsoft Excel Programming 7 26th May 2006 07:49 PM
Re: Can I use ISERROR with VLOOKUP function? Alex Hatzisavas Microsoft Excel Programming 1 22nd Sep 2004 06:57 PM
RE: Can I use ISERROR with VLOOKUP function? =?Utf-8?B?UHJhYmhh?= Microsoft Excel Programming 0 21st Sep 2004 05:05 PM
Can I use ISERROR with VLOOKUP function? Frank Kabel Microsoft Excel Programming 0 20th Sep 2004 04:36 PM
Can I use ISERROR with VLOOKUP function? =?Utf-8?B?UHJhYmhh?= Microsoft Excel Programming 0 20th Sep 2004 03:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.