Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Fill cells with pseudo-random values

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Fill cells with pseudo-random values

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

"SANTANDER" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Fill cells with pseudo-random values

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

"SANTANDER" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Fill cells with pseudo-random values

When paste this code, its not recognized as macro - nothing to run.

santander


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

"SANTANDER" wrote:

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Fill cells with pseudo-random values

Hi,
yes it works.

thanks.
~~~~~~~~~

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

"SANTANDER" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i fill cells with random color? Casey Excel Programming 7 May 24th 10 11:14 AM
fill any random cell in a column and block all other cells SK Excel Discussion (Misc queries) 5 October 12th 09 07:20 PM
How can I fill a block of 300 cells with non-repeating random #s nerkaman Excel Discussion (Misc queries) 1 July 3rd 09 08:16 PM
fill random cells hulub[_2_] Excel Programming 0 September 20th 04 05:44 AM
fill random cells hulub Excel Programming 1 September 19th 04 08:26 PM


All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"