Recursion with user defined functions

B

bigJim

My problem, is that Excel (I am using excel 2003) seems
to reenter the user function, but never completes the
first call and gets confused. (I get very confuded).

I would appreciate any assistence.


I want the user to select from a list box, and for the
response to feed a few cells.

eg. List Box =
"7 table Mitchell",
"8 table Mitchell",
"6 table Howell"
etc.

I have formulas on the two target cells as follows :-
Cell NoTables = UserFunction("NoTables") ' 7, 8, 6
Cell NoBoards = UserFunction("NoBoards") ' 24, 32

I have the following user function :-

Public Function UserFunction (cString As String) As
Integer

Dim iNoBoards As Integer
Dim iNoTables As Integer

Dim cMovementName As String
cMovementName = Range("MovementName").Cells(1,
1).Value

Dim rFound As Range
Set rFound = Range("MovementNames").Find
(cMovementName, LookIn:=xlValues)
If Not rFound Is Nothing Then
' We found the value.
iNoBoards = rFound.Cells(0, 1).Value
iNoTables = rFound.Cells(0, 2).Value
Else
' Value not found.
iNoBoards = 24
iNoTables = 8
End If
Set rFound = Nothing

If (cString = "No Boards") Then UserFunction =
iNoBoards
If (cString = "No Tables") Then UserFunction =
iNoTables

End Function
 
T

Tom Ogilvy

There doesn't seem to be anything recursive about your function.

Perhaps the combination of functions you have in your worksheet are causing
the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top