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

I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Random Numbers

What are the range of numbers from which you are choosing?

1 to 10?

20 to 77 ?

--
Regards,
Tom Ogilvy



"Leon" wrote:

I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Random Numbers

Let's say you want the randbetween to be between 1 and 100.

1. enter the numbers 1 thru 100 in cells A1 thru A100
2. enter =RAND() in cells B1 thru B100
3. sort cols A&B by B
for the first pair select A1 & A2
for the second pair select A3 & A4
..
..
..
--
Gary's Student


"Leon" wrote:

I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Random Numbers

Leon,

A simple way would be to list your valid pairs in columns A and B, then use the formula

=RAND()

in column C, matching your list in columns A and B. When you want a new set or random pairs, force
a calculation, and then sort based on column C, and take the top 8 pairs from Columns A and B.

HTH,
Bernie
MS Excel MVP


"Leon" wrote in message
...
I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Random Numbers

Thanks, Tom, Gary & Bernie.
I need 8 pairs of rtandom numbers from 0 to 4
I guess Bernie's solution is the lightest to implement once I write all the
possible pairs. Which I guess amount to 20.

Thanks to all


"Bernie Deitrick" wrote:

Leon,

A simple way would be to list your valid pairs in columns A and B, then use the formula

=RAND()

in column C, matching your list in columns A and B. When you want a new set or random pairs, force
a calculation, and then sort based on column C, and take the top 8 pairs from Columns A and B.

HTH,
Bernie
MS Excel MVP


"Leon" wrote in message
...
I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Random Numbers

Sub Writeallpairs()
Dim i As Long, j As Long, k As Long
Dim rng As Range
Range("A:C").ClearContents
j = 1
For i = 0 To 4
For k = 0 To 4
If i < k Then
Cells(j, 1) = i: Cells(j, 2) = k
j = j + 1
End If
Next k, i
Set rng = Cells(1, 1).Resize(j - 1, 1)
rng.Offset(0, 2).Formula = "=rand()"
Range("A1").Resize(j - 1, 3).Sort Key1:=Range("C1")
Columns(3).ClearContents
Set rng = Range(Cells(9, 1), Cells(Rows.Count, 1).End(xlUp))
rng.EntireRow.Delete
End Sub


--
Regards,
Tom Ogilvy




"Leon" wrote:

Thanks, Tom, Gary & Bernie.
I need 8 pairs of rtandom numbers from 0 to 4
I guess Bernie's solution is the lightest to implement once I write all the
possible pairs. Which I guess amount to 20.

Thanks to all


"Bernie Deitrick" wrote:

Leon,

A simple way would be to list your valid pairs in columns A and B, then use the formula

=RAND()

in column C, matching your list in columns A and B. When you want a new set or random pairs, force
a calculation, and then sort based on column C, and take the top 8 pairs from Columns A and B.

HTH,
Bernie
MS Excel MVP


"Leon" wrote in message
...
I need a formula/macro to display a set of 8 pairs of random numbers.
Each number in a pair cannot be equal to the other, numbers in a pair can be
equal to the ones in an other pair.
I tried Randbetween(a,b) but i get a lot of invalid(equal) pairs.

Any help will be gratefully appreciated.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Random Numbers

Hello Leon,

Select two cells and enter
=UniqRandInt(5)-1
as array formula (CTRL + SHIFT + ENTER).

Enter my UDF into a module:
http://www.sulprobil.com/html/uniqrandint.html

HTH,
Bernd

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 08:01 AM.

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"