ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   In Excel How Do I Random a Number but Not when it recalculates? (https://www.excelbanter.com/excel-discussion-misc-queries/178110-excel-how-do-i-random-number-but-not-when-recalculates.html)

TxcPhtm

In Excel How Do I Random a Number but Not when it recalculates?
 
I am trying to make a Macro that will select a few cells and random number
between 1-100 (I have done this). But when I use =RANDBETWEEN(1,100) whenever
I change a number in my cells it randoms. I was wondering whether there was a
=random that doesnt do after every recalculate. Or a Macro term.

JP[_4_]

In Excel How Do I Random a Number but Not when it recalculates?
 
Why not just paste in the value after you use the formula? I believe
all of the random functions (RAND, etc) are volatile.

HTH,
JP

On Feb 27, 4:56*pm, TxcPhtm wrote:
I am trying to make a Macro that will select a few cells and random number
between 1-100 (I have done this). But when I use =RANDBETWEEN(1,100) whenever
I change a number in my cells it randoms. I was wondering whether there was a
=random that doesnt do after every recalculate. Or a Macro term.



TxcPhtm

In Excel How Do I Random a Number but Not when it recalculates
 
Thats not what I meant I mean so when i click a button they change

Bob I

In Excel How Do I Random a Number but Not when it recalculates
 
Press the F9 button.

TxcPhtm wrote:

Thats not what I meant I mean so when i click a button they change



joeu2004

In Excel How Do I Random a Number but Not when it recalculates?
 
On Feb 27, 1:56*pm, TxcPhtm wrote:
I am trying to make a Macro that will select a few cells and
random number between 1-100 (I have done this). But when
I use =RANDBETWEEN(1,100) whenever I change a number
in my cells it randoms. I was wondering whether there was a
=random that doesnt do after every recalculate. Or a Macro term.


I am a little confused. On the one hand, you say are "trying to make"
a macro that does this; on the other hand, you say you are using
=RANDBETWEEN(1,100), presumably in an Excel cell. Moreover, you say
that "a macro" will select a few cells. Usually, you select the
cells, then execute a macro to operate on the selected cells.
(Although, of course, you can indeed write the macro so that it makes
the selection.)

Be that as it may, you might be able to accomplish your task (whatever
that is) by computing the random number(s) within the macro. In Excel
2007, you might be able to use WorkSheetFunction.Randbetween, since I
believe the RANDBETWEEN() is now a standard Excel function. I don't
know; I cannot do that in Excel 2003. Alternatively, you can write
your own function, namely:

Function myRandBetween(low As Long, high As Long) As Long
myrandbetween = low + Int((high - low + 1) * Rnd())
End Function


All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com