LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
CarlosAntenna
 
Posts: n/a
Default Shortening a vlookup

I also use this same kind of construct often. (vlookup with error trap) I
cut and pasted the code into the "this workbook" object and used the taz
function in a worksheet but I get a #NAME error. What am I doing wrong? I
also tried putting it in the sheet objects -- same error.

My formula in B2 is: =taz(A2,Sheet1!A:B,2)

This would be very useful to me but I never thought of defining my own
function.
--
Carlos

"Bob Phillips" wrote in message
...
Try this version

Function taz(a, b, c)

On Error Resume Next
taz = WorksheetFunction.VLookup(a, b, c, 0)
On Error GoTo 0
If IsEmpty(taz) Then
taz = 5
End If
End Function


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"T De Villiers"


wrote in message
news:T.De.Villiers.228spa_1138279803.9027@excelfor um-nospam.com...

Thanks for this, another question though, just say I want the output to
be 5
when there is an error, why doesnt the following work, many thanks:

Function taz(a, b, c)

On Error Resume Next
taz = WorksheetFunction.VLookup(a, b, c, 0)
On Error GoTo 0
If IsError(taz) Then
taz = 5
End If
End Function


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile:

http://www.excelforum.com/member.php...o&userid=26479
View this thread:

http://www.excelforum.com/showthread...hreadid=505271







 
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
Using single cell reference as table array argument in Vlookup CornNiblet Excel Worksheet Functions 3 September 22nd 05 09:15 AM
VLOOKUP Limitations chris_manning Excel Worksheet Functions 2 August 9th 05 06:23 PM
Have Vlookup return a Value of 0 instead of #N/A Mr Mike Excel Worksheet Functions 4 May 25th 05 04:51 PM
vlookup data hidden within worksheet Excel Worksheet Functions 0 January 26th 05 12:09 PM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


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

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

About Us

"It's about Microsoft Excel"