Using VBA in Excel 2016. The rand() function is not defined.
My addins are :
Analysis Toollpack and
Analysis Toollpack VBA
What is the problem, what is an alternative?
Using VBA in Excel 2016. The rand() function is not defined.
My addins are :
Analysis Toollpack and
Analysis Toollpack VBA
What is the problem, what is an alternative?
Rand() is the worksheet function
Rnd() is the VBA function
https://docs.microsoft.com/en-us/off...6)%26rd%3Dtrue
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
I replaced the failed statement with this and it worked:
Well almost. It ran for 600,000 data points. Then there was a weird failure with the error message:DataPoint = Application.WorksheetFunction.NormInv(Rnd(), MeanNow, SD)
I clicked [debug], and F5, and it continued running to a total of 2,500,000 numbers without any more errors.Run-time error "1004" Unable to get Norminv property of the WorksheetFunction class
The error is repeatable.
Show the code
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Solved: this works:
Function MyRandomNormal2() As Double Dim Uniform As Double Uniform = Evaluate("=rand()") MyRandomNormal2 = Application.WorksheetFunction.NormInv(Uniform, MeanNow, SD) End Function