CJ said:
Excel 2003. How can I switch from volatile to non-volatile?
I don't want randomly generated numbers to change every
time the enter button is pushed or a cell is modified.
Create the following UDF:
Function myRAND(Optional r As Range) As Double
myRAND = Evaluate("RAND()")
End Function
(There are advantages of using Evaluate("RAND()") instead of VBA Rnd.)
You can call it as =myRAND(). It will not change until the entire worksheet
is recalculated, or you cause that cell to be recalculated (e.g. press F2,
Enter).
You can call is as =myRAND(B1). It will not change until B1 is
recalculated, or the entire worksheet is recalculated, or you cause that cell
to be recalculated.
Similarly, you have the following UDF:
Function myRANDBETWEEN(lo As Double, _
hi As Double, Optional r As Range) As Double
myRANDBETWEEN = _
Evaluate("RANDBETWEEN(" & lo & "," & hi & ")")
End Function
You wrote in another message:
I don't want the randomly generated questions to
change value until after the child has completed
all of the questions.
If all your questions use myRANDBETWEEN(10,99,B1), for example, you can
create a button to execute the following macro:
Sub newQuestions()
Range("b1") = ""
End Sub
To associate a button with the macro, click on View > Toolbars > Forms.