Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Unexpectedly calls a Function | Excel Programming | |||
Using ODBC function calls | Excel Programming | |||
excel vba problem - function calls from cells | Excel Programming | |||
identifying which cell calls my VBA function. | Excel Programming | |||
function calls | Excel Programming |