ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Custom Function (https://www.excelbanter.com/excel-programming/316474-help-custom-function.html)

Flamikey[_7_]

Help with Custom Function
 

Hi,
I know very little about VBA....I am trying to create a user define
function. I use the following formula all the time and wanted to sav
it as a function to save time....
=IF(ISERROR(VLOOKUP(LOOKUP_VALUE,TABLE_ARRAY,COL_I NDEX_NUM,RANGE_LOOKUP),0,VLOOKUP(LOOKUP_VALUE,TABL E_ARRAY,COL_INDEX_NUM,RANGE_LOOKUP)

I inserted a new module in VBA to create the function and worte th
following( I am sure I am way off)......

Function Noerorvlookup(Lookup, Range, Column)
Noerrorvlookup
IF(ISERROR(VLOOKUP,Lookup,Range,Column,False),0,VL OOKUP,Lookup,Range,Column,False))
End Function

Can anyone help fix my horrible code?

Thanks!

--
Flamike
-----------------------------------------------------------------------
Flamikey's Profile: http://www.excelforum.com/member.php...nfo&userid=461
View this thread: http://www.excelforum.com/showthread.php?threadid=27740


Tom Ogilvy

Help with Custom Function
 
Function Noerorvlookup(Lookup As Variant, Rng As Range, Col As Long)
Dim res as Variant
res = Application.VLookup(Lookup, Rng, Col, False)
If IsError(res) Then
Noerorvlookup = 0
Else
Noerorvlookup = res
End If
End Function

--
Regards,
Tom Ogilvy

"Flamikey" wrote in message
...

Hi,
I know very little about VBA....I am trying to create a user defined
function. I use the following formula all the time and wanted to save
it as a function to save time....

=IF(ISERROR(VLOOKUP(LOOKUP_VALUE,TABLE_ARRAY,COL_I NDEX_NUM,RANGE_LOOKUP),0,V
LOOKUP(LOOKUP_VALUE,TABLE_ARRAY,COL_INDEX_NUM,RANG E_LOOKUP)

I inserted a new module in VBA to create the function and worte the
following( I am sure I am way off)......

Function Noerorvlookup(Lookup, Range, Column)
Noerrorvlookup =

IF(ISERROR(VLOOKUP,Lookup,Range,Column,False),0,VL OOKUP,Lookup,Range,Column,
False))
End Function

Can anyone help fix my horrible code?

Thanks!!


--
Flamikey
------------------------------------------------------------------------
Flamikey's Profile:

http://www.excelforum.com/member.php...fo&userid=4612
View this thread: http://www.excelforum.com/showthread...hreadid=277409





All times are GMT +1. The time now is 12:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com