Randomizing Hell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello –

I pick up a percentage from a given cell and based on some preset variance,
say +/-10%, I need to randomly assign a new percentage to a block of cells
elsewhere, based on that driver’s range. So if the driver is 30% and the
variance is +/-10% the range to randomly be applied to a block of cells
elsewhere would be between 27%, 28%, 29%... to 33%. Each cell in that block
getting a random number from that range. I have most of the looping
components down; I just keep tripping over the above scenario and am not
finding the pieces to put together.

Any direction is greatly appreciated.
Sincerely,
Arturo
 
Arturo,

Te following code shows how to calculate your random numbers:

Sub GenRand()
Dim Driver As Double
Dim Var As Double
Dim Result As Double

Driver = 0.3
Var = 0.1

Result = (1 - Var) * Driver + 2 * Rnd() * Var * Driver

MsgBox Result

End Sub

(1-Var)*Driver gives you the 27% base you need.

2*Var*Driver gives you the 6% range to be added. Applying Rnd() to this
gives a random number in the range.
 

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

Back
Top