Skip to content

Excel Fill Handle function call #545

Answered by govert
schebotar asked this question in Q&A
Discussion options

You must be logged in to vote

If you mark your function as volatile with [ExcelFunction(IsVolatile=true)] it will recalculate and return a new value every time the sheet calculates, just like the built-in =RAND() function.
To get a good distribution of random numbers, you should also create one instance of the .NET 'Random' class, and use that one repeatedly.


       static Random _rand = new Random();

       [ExcelFunction(IsVolatile=true)]
        public static double Random()
        {
            return _rand.NextDouble();
        }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by schebotar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants