Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Custom function to simplify vlookup formula

I want to have custom functions that will simplify vlookups (and other
formulas) which have imbedded "if" formulas to eliminate errors. e.g.This
formula provided in a previous posting is ugly and somewhat annoying:
=IF(ISERROR(VLOOKUP($A2,Stock,2,0)),"",VLOOKUP($A2 ,Stock,2,0))

Can I replace it with a custom function that works the same but looks
something like this:
=MyVLookup($A2,Stock,2,0)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Custom function to simplify vlookup formula

Public Function myLookup(lookup_value, _
table_array As Range, _
col_index_num As Long, _
Optional range_lookup As Boolean = True)
Dim tmp
On Error Resume Next
tmp = Application.VLookup(lookup_value, table_array, col_index_num,
range_lookup)
On Error GoTo 0
If IsError(tmp) Then
myLookup = ""
Else
myLookup = tmp
End If
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John James" wrote in message
...
I want to have custom functions that will simplify vlookups (and other
formulas) which have imbedded "if" formulas to eliminate errors. e.g.This
formula provided in a previous posting is ugly and somewhat annoying:
=IF(ISERROR(VLOOKUP($A2,Stock,2,0)),"",VLOOKUP($A2 ,Stock,2,0))

Can I replace it with a custom function that works the same but looks
something like this:
=MyVLookup($A2,Stock,2,0)




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Custom function to simplify vlookup formula

Many thanks, Bob.

With the tmp equation all on one line it looks like it works like a charm!!!
I'll be using this on various other XL formulas to eliminate the need for
those annoying if(iserror(... portions of formulae. Beautiful!!!!

Cheers,

"Bob Phillips" wrote in message
...
Public Function myLookup(lookup_value, _
table_array As Range, _
col_index_num As Long, _
Optional range_lookup As Boolean = True)
Dim tmp
On Error Resume Next
tmp = Application.VLookup(lookup_value, table_array, col_index_num,
range_lookup)
On Error GoTo 0
If IsError(tmp) Then
myLookup = ""
Else
myLookup = tmp
End If
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John James" wrote in message
...
I want to have custom functions that will simplify vlookups (and other
formulas) which have imbedded "if" formulas to eliminate errors.
e.g.This
formula provided in a previous posting is ugly and somewhat annoying:
=IF(ISERROR(VLOOKUP($A2,Stock,2,0)),"",VLOOKUP($A2 ,Stock,2,0))

Can I replace it with a custom function that works the same but looks
something like this:
=MyVLookup($A2,Stock,2,0)






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Custom function to simplify vlookup formula

Hello,

I try this and work perfectly!!!. Do you know how to custom this in the same
way:

=IF(ISERROR(INDEX(A1:C3,MATCH(D2,A1:A3,),MATCH(E1, A1:C1,))),"",INDEX(A1:C3,MATCH(D2,A1:A3,),MATCH(E1 ,A1:C1,)))

Thanks in advance

"Bob Phillips" wrote:

Public Function myLookup(lookup_value, _
table_array As Range, _
col_index_num As Long, _
Optional range_lookup As Boolean = True)
Dim tmp
On Error Resume Next
tmp = Application.VLookup(lookup_value, table_array, col_index_num,
range_lookup)
On Error GoTo 0
If IsError(tmp) Then
myLookup = ""
Else
myLookup = tmp
End If
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"John James" wrote in message
...
I want to have custom functions that will simplify vlookups (and other
formulas) which have imbedded "if" formulas to eliminate errors. e.g.This
formula provided in a previous posting is ugly and somewhat annoying:
=IF(ISERROR(VLOOKUP($A2,Stock,2,0)),"",VLOOKUP($A2 ,Stock,2,0))

Can I replace it with a custom function that works the same but looks
something like this:
=MyVLookup($A2,Stock,2,0)





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
simplify VLOOKUP with conditions tjtjjtjt Excel Worksheet Functions 1 January 23rd 07 07:38 PM
Custom function to simplify Index(match)) formula Martin Excel Discussion (Misc queries) 0 March 20th 06 02:45 PM
Custom Function VLookup Martin Excel Discussion (Misc queries) 1 March 15th 06 08:32 PM
simplify a vlookup function Caveman Excel Worksheet Functions 1 September 26th 05 03:39 PM
Simplify Vlookup function in Excel Budman Excel Worksheet Functions 7 March 27th 05 04:17 PM


All times are GMT +1. The time now is 01:29 AM.

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"