Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

(How to) generate a different random number each time?

$
0
0
Currently I have these code:

Quote:

Sub dt() ' calculate dwell time, peak hour=1, non-peak=0
If peaktime = 1 Then
dwelltime = 30 + 30 * Rnd
Else: dwelltime = 20 + 20 * Rnd
End If
End Sub
However, for each time the value of 'dwelltime' is the same (34.011) How can I randomize this value?

Viewing all articles
Browse latest Browse all 50061

Trending Articles