Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Condense ISERROR(VLOOKUP(MATCH())) to VBA 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","")

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default Condense ISERROR(VLOOKUP(MATCH())) to VBA function.

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 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default Condense ISERROR(VLOOKUP(MATCH())) to VBA function.

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 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 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 -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Condense ISERROR(VLOOKUP(MATCH())) to VBA function.

On Dec 11, 4:14 pm, ilia 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 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 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IsError and Match function GDCross Excel Programming 7 May 26th 06 07:49 PM
Can I use ISERROR with VLOOKUP function? Alex Hatzisavas[_2_] Excel Programming 1 September 22nd 04 06:57 PM
Can I use ISERROR with VLOOKUP function? Prabha Excel Programming 0 September 21st 04 05:05 PM
Can I use ISERROR with VLOOKUP function? Frank Kabel Excel Programming 0 September 20th 04 04:36 PM
Can I use ISERROR with VLOOKUP function? Prabha Excel Programming 0 September 20th 04 03:29 PM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"