Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Calling the function from another function or sub wouldn't be a problem.
It'll be a problem when the function originates in a cell on a worksheet. We'll see (maybe) who guessed right <vbg. Jim Cone wrote: Hi Dave, I called the function from a sub. The ActiveCell had "=RAND()" in it... '--- Sub huh() MsgBox expval(ActiveCell, 5) End Sub '--- Jim Cone Portland, Oregon USA "Dave Peterson" wrote in message About the only thing that a function called from a worksheet cell can do is return a value to the cell with the function. Application.calculate fails for me (xl2003). Maybe you could use VBA's Rnd function instead of looking back at the worksheet??? Option Explicit Function expval(Optional iter As Long) As Double Dim arr() As Double Dim loops As Integer Dim X As Long Randomize 'set itterations loops = Application.WorksheetFunction.Max(iter, 20) 'set array ReDim arr(1 To loops) 'loop through value measurements For X = 1 To loops arr(X) = Rnd Next X 'compute average value expval = Application.WorksheetFunction.Average(arr) End Function Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
use time functions inside if loop | Excel Worksheet Functions | |||
Can an array be redim inside a for loop? | Excel Programming | |||
form inside a loop | Excel Programming | |||
Increment stopvalue inside a For loop | Excel Programming | |||
Create an array inside a For...Next loop | Excel Programming |