LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Problem with a function that calls itself

Hi,

I created a function that emulates the Excel function LOOKUP but that
does not require the lookup table to be sorted.

It works fine, except when the first parameter is a call to itself,
that is, when nesting the function.

For example:

In M27:M31 if I input the array function:
={vslookup(C6:C10;H6:H8;J6:J8)} 'it works fine

In N27:N31 if I input the array function:
={vslookup(M27:M31;W26:W27;X26:X27)} 'it works fine (the first
argument is the result of the previous function)

However, if I nest the 2 formulas in O27:O31::
={vslookup(vslookup(C6:C10;H6:H8;J6:J8);W26:W27;X2 6:X27)} ' I get
#VALUE!

What is the problem with nesting?


Function VSLookup(a, b, c)
' a, b y c son rangos verticales
' el número de filas de b y c es el mismo
Dim i, j, nrows
ReDim T(a.Rows.Count, 1)
For i = 1 To a.Rows.Count
For j = 1 To b.Rows.Count
If a(i, 1) = b(j, 1) Then
T(i, 1) = c(j, 1)
GoTo aqui
End If
Next j
T(b.Rows.Count, 1) = CVErr(xlErrNA)

aqui:
Next i
VSLookup = T
End Function
 
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
Macro Unexpectedly calls a Function Steve Excel Programming 5 January 11th 09 07:31 PM
Using ODBC function calls Dave[_64_] Excel Programming 0 February 15th 06 02:37 PM
excel vba problem - function calls from cells internerdj Excel Programming 6 July 7th 04 10:18 PM
identifying which cell calls my VBA function. y Excel Programming 3 April 26th 04 04:32 AM
function calls Claude Excel Programming 2 December 5th 03 01:55 PM


All times are GMT +1. The time now is 06:23 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"