Full Version: Random Number
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
Yossii
Hiya
I';ve created a Random Number thingie

=Rand()*20

Formatted the result to zero decimal places no prob.

The problem is when i do things to the spreadsheet the numbers change.

How do I stop this happening pls ?

Cheers
argeedblu
Your formulat will recalculate whenever the worksheet recalcuates. To preserve the list of random numbers, copy the list and then do a paste/special Values to replace the formula with the values it has generated.

Glenn
KingMartin
Hello,

there's one more possibility... write an UDF, e.g.:

CODE
[color="blue"]Function[/color] [color="blue"]Random[/color](Lower [color="blue"]As[/color] [color="blue"]Long[/color], Upper [color="blue"]As[/color] [color="blue"]Long[/color])
    [color="blue"]Random[/color] = Lower + Int(Rnd() * (Upper - Lower + 1))
[color="blue"]End[/color] [color="blue"]Function[/color]


and use like

=RANDOM(1,10)

in your worksheet.

It will recalculate only if you force full recalculation, by pressing Ctrl+Alt+F9

Martin
argeedblu
That is a nice variation, Martin. I didn't realize that UDFs don't auto recalculatate.

Glenn
KingMartin
No they don't... unless you use ranges as parameters sad.gif

Martin
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.