Random Number

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am generating a random number as follows:
=RANDBETWEEN(10000000;99999999)

How can I make the cell recalculate a new random number every time I
click the cell?

Is this possible?

Thanks,
Miguel
 
On the off chance you don't know this, just pressing F9 will cause the sheet
to recalc. Since RANDBETWEEN() is volatile, it will recalc.

Otherwise you can use a macro to do it. Right-click on the sheet tab and
select VIEW CODE. Paste in this macro to the sheet module that appears:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$5" Then
Calculate
Range("C5").Select
End If
End Sub


Edit the $B$5 to the cell where you want it to watch. Then close the editor
and save the sheet. Now, click on any other cell, then click on B5. It
should reassert a new value each time you click on it.

Does that help?
 
On the off chance you don't know this, just pressing F9 will cause the sheet
to recalc. Since RANDBETWEEN() is volatile, it will recalc.

Otherwise you can use a macro to do it.  Right-click on the sheet tab and
select VIEW CODE. Paste in this macro to the sheet module that appears:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$B$5" Then
        Calculate
        Range("C5").Select
    End If
End Sub

Edit the $B$5 to the cell where you want it to watch. Then close the editor
and save the sheet.  Now, click on any other cell, then click on B5. It
should reassert a new value each time you click on it.

Does that help?
--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.

I will use F9.

Thanks,
Miguel
 
Back
Top