Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default random numbers

I am trying to generate a list of random numbers based on the results in a
couple cells.

Cell C3 contains a number that is input by the user.

Cell C5 contains the results of a formula - related to the number in C3

I would like to create X number of random numbers, where X = C5, and all of
the random numbers must be integers between 1 and the value in cell C3

I've tried a few things based on some other posts, and using some sorting,
but haven't been able to do this successfully. Any help / suggestions would
be appreciated.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default random numbers

On Tue, 22 Jul 2008 10:41:04 -0700, tomic
wrote:

I am trying to generate a list of random numbers based on the results in a
couple cells.

Cell C3 contains a number that is input by the user.

Cell C5 contains the results of a formula - related to the number in C3

I would like to create X number of random numbers, where X = C5, and all of
the random numbers must be integers between 1 and the value in cell C3

I've tried a few things based on some other posts, and using some sorting,
but haven't been able to do this successfully. Any help / suggestions would
be appreciated.

Thanks.


Assuming that you want your random numbers in the D column, try the
following formula in Cell D1:

=IF(ROW()<=C$5,RANDBETWEEN(1,C$3),"")

Copy this down as long as needed to cover the maximum number of random
numbers that might be relevant.

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default random numbers

In D1 enter:

=IF(ROW()C$5,"",RANDBETWEEN(1,C$3)) and copy down
--
Gary''s Student - gsnu200795


"tomic" wrote:

I am trying to generate a list of random numbers based on the results in a
couple cells.

Cell C3 contains a number that is input by the user.

Cell C5 contains the results of a formula - related to the number in C3

I would like to create X number of random numbers, where X = C5, and all of
the random numbers must be integers between 1 and the value in cell C3

I've tried a few things based on some other posts, and using some sorting,
but haven't been able to do this successfully. Any help / suggestions would
be appreciated.

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default random numbers

'/=============================/
Sub Macro1()
Dim dbl As Double
Dim dblMax As Double
Dim dblRandNos As Double

'put random #s in row starting at Cell D1
Range("D1").Select

'clear Column D of old info
Range("D:D").ClearContents

'get values in C3 and C5
dblMax = Range("C3").Value2
dblRandNos = Range("C5").Value2

'create random #s
For dbl = 1 To dblRandNos
ActiveCell.Offset(dbl - 1, 0).Value = _
Int(Rnd() * dblMax) + 1
Next dbl

End Sub
'/=============================/

--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"tomic" wrote:

I am trying to generate a list of random numbers based on the results in a
couple cells.

Cell C3 contains a number that is input by the user.

Cell C5 contains the results of a formula - related to the number in C3

I would like to create X number of random numbers, where X = C5, and all of
the random numbers must be integers between 1 and the value in cell C3

I've tried a few things based on some other posts, and using some sorting,
but haven't been able to do this successfully. Any help / suggestions would
be appreciated.

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default random numbers

Thanks Gary.

Works Great.

The other responses look easy too...however, I got an unrecognized name
error. I'm using Excel 2003 - is randbetween a formula in 2007?



"Gary Brown" wrote:

'/=============================/
Sub Macro1()
Dim dbl As Double
Dim dblMax As Double
Dim dblRandNos As Double

'put random #s in row starting at Cell D1
Range("D1").Select

'clear Column D of old info
Range("D:D").ClearContents

'get values in C3 and C5
dblMax = Range("C3").Value2
dblRandNos = Range("C5").Value2

'create random #s
For dbl = 1 To dblRandNos
ActiveCell.Offset(dbl - 1, 0).Value = _
Int(Rnd() * dblMax) + 1
Next dbl

End Sub
'/=============================/

--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"tomic" wrote:

I am trying to generate a list of random numbers based on the results in a
couple cells.

Cell C3 contains a number that is input by the user.

Cell C5 contains the results of a formula - related to the number in C3

I would like to create X number of random numbers, where X = C5, and all of
the random numbers must be integers between 1 and the value in cell C3

I've tried a few things based on some other posts, and using some sorting,
but haven't been able to do this successfully. Any help / suggestions would
be appreciated.

Thanks.

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
Random Numbers excluding Previous Numbers Brad Excel Worksheet Functions 2 July 23rd 09 12:25 AM
getting numbers divisible by 4 from random numbers in ascending order ramana Excel Worksheet Functions 6 June 19th 07 06:41 PM
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM


All times are GMT +1. The time now is 07:10 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"