Is there a way to make this non-volitile
You want the number to stay the same after it is entered, correct? One way
to do that would be to call it from a sub. In the same module you defined
the function, you could try something like this:
Sub RunRoll2D6()
Dim thecell As Range
Set thecell = ActiveCell
On Error Resume Next
If ActiveCell.Value = "" Then
thecell.Value = Roll2D6()
Range(ActiveCell).Copy thecell.PasteSpecial(xlPasteValues)
End If
End Sub
Then, call the sub instead of typing the function.
--
tj
"Adam Kroger @hotmail.com" wrote:
This is the UDF
Function ROll2D6()
ROll2D6 = Application.RoundUp(Rnd() * 6, 0) + Application.RoundUp(Rnd()
* 6, 0)
End Function
At current, when Excel recalculates, the random number generated by this
function, is replaced by another rnadom nuber.
Is there some sort of check that I can put into the UDF whereby IF the
current value of the cell (calling the function) is a number, it will return
that number instead of a new one.?
Thanks
|