Random Number

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
 
J

JBeaucaire

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?
 
S

shapper

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top