JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,532
- Office Version
- 365
- Platform
- Windows
I need to write a UDF that will generate an array of data from a Normal Distribution, test the data, and return it to the calling sheet. I will pass it the mean, standard deviation, and the number of data points.
Here's the skeleton of the code. I need help with the details.
Do I generate the data in the sheet or in a variable in the UDF?
Thanks for any help.
Here's the skeleton of the code. I need help with the details.
VBA Code:
Function BestNorm(pMean As Double, pStdDev As Double, pN As Long)
'Define the variables. I need an array of pN rows by 1 column
Do
'Generate N data points using this worksheet function:
'=ROUND(NORM.INV(RANDARRAY(pN),pMean,pStdDev),0)
'Do some tests on the data
'If the tests are succfessful, Exit Do
'Loop
Loop
'Return the array of data to the calling sheet
End Function
Do I generate the data in the sheet or in a variable in the UDF?
Thanks for any help.