# Excel randomizer question on
i have a spreadsheet with a data set that i want to interpret graphical with a bar chart.  The problem i have is that i only have totals and i want the graph to illustrate variations.  I have tried to make clear on the data file i included what kind of formula i am looking for but to restate...the blank cells in the worksheet need values and i want control how those values are generated.  I also would like the graph to not look so extreme since one set of values is much higher than the other data sets.

thanks
Comment
Watch Question

Do more with EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
no data file
Project finance

Commented:
excel data file attached
Book2.xlsx
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
pdvsa,
This question would be easier go get a handle on if your workbook showed the type of numbers you want to be randomly generated.

Assuming that you want the numbers to approximate a random movement between the two extremes in C7 and C13, you might use a formula in cell C8 like:
=C\$7+(C\$13-C\$7)*RAND()*ROWS(C\$8:C8)/3            'can be copied down

The RAND() gives a random number between 0 and 1--with an average value of 0.5

As you copy ROWS(C\$8:C8) down, it returns the numbers 1 through 5.

If you would have copied ROWS(C\$8:C8) down through C13, the last value would have been 6. This is convenient, because you would have six random numbers whose average values are 1/6, 2/6, 3/6, 4/6, 5/6 and 6/6. Had RAND() returned exactly 0.5 in row 13, then the formula would have returned C\$7+(C\$13-C\$7)*0.5*6/3 = C\$13.

Project finance

Commented:
Thanks Brad.  The workbook example i provided has the numbers in currency format and the values i am looking for should be in descending/ascending order from row 7 to 13 and vice versa.

This is a sample data set of a larger worksheet and i am looking for a formula to copy/paste.  I used the formula you provided but the values it generated where identical for every cell.  I tried a few variations but kept getting the same identical values.

This variation:

=C\$7+(C\$13-C10)*RAND()*ROWS(C\$8:C\$12)/5

on the formula would seem to provide the desired result but it generates an identical value...\$13,879,069.83.   Is there something i am missing in the syntax.
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
pdvsa,
Here is how I imagined using the formula.

Book2Q27731257.xlsx
Project finance

Commented:

i think i see the syntax...i will work with  this syntax.  thanks
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
Another type of random number formula would permit random progress from the value in C7 to that in C13, but with no backtracking. Try the following in cell C8:
=C7+(C\$13-C7)*RAND()*2/ROWS(C8:C\$13)                 formula may be copied down

The above formula would be typical of sales volume--always increasing, but with variation in the month to month amounts.
Project finance

Commented:
i attached a sheet with the second formula,  gave no effect,  graphs are inconsistent when i copied values.  Is something missing in my how i copy the data values?
Book2Q27731257.xlsx
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
pdvsa,
The title of the question suggests that random numbers are required in a steadily changing range between the values in C7 and C13. I therefore suggested a formula using the RAND function. RAND will change value every time you enter data, no matter whether by typing it in or by copy & paste. That's why your two charts look different--it's by design.

If it is essential that the copy look just like the original data, change the calculation mode to manual before the copy & paste.

Project finance

Commented:

For columns F & G the randomness needs to sum to the total of row 13 and those sums need to loosely reflect the decreasing value of column C.  I had never altered the calculation mode  before so i will give that a shot, but i dont think the Rand function alone will give me the numbers i need...i am looking at either adding an if, and, or statement or using a different function.  Have a made it clear what sort of random numbers i am looking for?
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
I changed my approach to use a macro to generate a column of random numbers in column D. These random numbers are updated only when the macro runs. You can then use them in a formula to vary your data. For extra measure, the random numbers vary between two extremes, stored in named ranges MinRand and MaxRand.

Formula for cell C8 (may be copied down):
=C\$7+(C\$13-C\$7)*D8*ROWS(C\$8:C8)/(ROWS(\$C\$8:\$C\$13)*AVERAGE(MinRand,MaxRand))
These values progress between the extremes in C7 and C13.

Formula for cell F7 (may be copied down or across):
=\$D7/SUM(\$D\$7:\$D\$12)*F\$13               'Values add up to sum in row 13

``````Sub Randomizer()
Dim cel As Range, rg As Range
Dim dMinRand As Double, dMaxRand As Double
Set rg = Worksheets("Sheet1").Range("D7:D12")   'Put random numbers in these cells
dMinRand = [MinRand]
dMaxRand = [MaxRand]
Randomize
For Each cel In rg.Cells
cel.Value = dMinRand + Rnd() * (dMaxRand - dMinRand)
Next
End Sub
``````
Book2Q27731257.xlsm
Project finance

Commented:
That's the ticket!!!

Do more with 