Fill cells with pseudo-random values

S

SANTANDER

excel spreadsheet, 5 columns, fourth column (D) contains no data.
I want fill column D with pseudo-random values: 350, 540, 750, 1500, 1200,
2000, 630, 450, 1800, 970 need be filled in cells in random order.
( entered in rows from 2 - 7303, not needs for all column)

Thanks,
santander
 
J

Joel

MyNums = Array(350, 540, 750, 1500, 1200, 2000, _
630, 450, 1800, 970)
ArraySize = UBound(MyNums) + 1

For RowCount = 2 To 7303
RanNum = Int(ArraySize * Rnd())
Range("D" & RowCount) = MyNums(RanNum)
Next RowCount
 
M

Mike H

Hi,

maybe this
Right click the sheet tab, view code and paste this in and run it

Sub stance()
For x = 2 To 7303
myvalue = Int((10 * Rnd) + 1)
Cells(x, 4).Value = Application.WorksheetFunction.Choose _
(myvalue, 350, 540, 750, 1500, 1200, 2000, 630, 450, 1800, 970)
Next
End Sub


Mike
 
S

SANTANDER

Hi,
yes it works.

thanks.
~~~~~~~~~

Mike H said:
Hi,

maybe this
Right click the sheet tab, view code and paste this in and run it

Sub stance()
For x = 2 To 7303
myvalue = Int((10 * Rnd) + 1)
Cells(x, 4).Value = Application.WorksheetFunction.Choose _
(myvalue, 350, 540, 750, 1500, 1200, 2000, 630, 450, 1800, 970)
Next
End Sub


Mike
 

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

Top