View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bryan Loeper Bryan Loeper is offline
external usenet poster
 
Posts: 19
Default Expression too complex

I added 'aaa' to every function name, still no dice.

On May 15, 12:44 pm, Barb Reinhardt
wrote:
Just a GUESS, but you are using function names that are built in functions.
Is there some reason you aren't using those? Alternatively, have you tried
changing the function name to something unique. Again, this is a GUESS.



"Bryan Loeper" wrote:
It varies. Sometimes it dies on Sum = Sum + Arr(i), sometimes on
Average = Sum(Arr) / Count(Arr). Neither of those _should_ be a
problem, but maybe I'm missing something.


-Bryan


On May 15, 12:26 pm, Barb Reinhardt
wrote:
You don't mention where it has a problem. Could you shed some light on that?


"bryan.loeper" wrote:
I'm getting intermittent "Runtime error '16': Expression too complex"
using the following code. It seems like if I step it through slowly,
it'll work for a while. What's wrong? I'm using Excel 11.8033.8036
with VBA 6.4.9972 if that matters, on Server 2003.


Option Explicit
Option Base 1


Private Function Sum(Arr() As Long) As Long
Sum = 0
If (Not Arr) < -1 Then
Dim i As Long
For i = LBound(Arr) To UBound(Arr)
Sum = Sum + Arr(i)
Next i
End If
End Function


Private Function Count(Arr() As Long) As Long
Count = UBound(Arr) - LBound(Arr) + 1
End Function


Private Function Average(Arr() As Long) As Double
Average = Sum(Arr) / Count(Arr)
End Function


Public Sub Test()
Dim x(1 To 30) As Long
Dim i As Long
For i = LBound(x) To UBound(x)
Randomize
x(i) = CInt(30 * Rnd) + 1
Next i
Debug.Print Average(x)
End Sub- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -