Forum Discussion

wayne gasson's avatar
wayne gasson
Copper Contributor
Oct 25, 2018

VBA Random Number

Hi All, I have created a Random Number Generator using the code below Private Sub CommandButton1_Click() Range("d2") = WorksheetFunction.RandBetween(-2, 2) Range("d3") = WorksheetFunction.R...
  • Man Fai Chan's avatar
    Oct 25, 2018

    You may consider the following:

     

    Range("F1") = WorksheetFunction.RandBetween(-2,2)   ' The first random number

    k = Range("F1")

    Range("F2") = WorkhseetFunction.RandBetween (k,2) 

    ' The second random number which lower bound depends on the previous random number

     

    Hop it helps. 

Resources