View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Green[_4_] John Green[_4_] is offline
external usenet poster
 
Posts: 47
Default Randomizing Hell

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.

--
John Green
Sydney
Australia


"Arturo" wrote in message
...
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