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

In a1:a20 I have numbers 1-20. I need to put these numbers randomly in
columns B to M without any numbers repeating across the rows. Is this
possible?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default generating random numbers without repeats

Hi,

If I understand correctly you want to pick 12 of these 20 numbers and put
them in B1 to M1 with no repeats. If so try this small macro.

ALT+F11 to open vb editor. Right click 'ThisWorkbook' and insert module and
paste the code in. Change the sheet name to the correct one and run it.

Sub Marine()
Dim FillRange As Range
Set Sht = Sheets("Sheet2") ' Change to suit
Set FillRange = Sht.Range("B1:M1")
For Each c In FillRange
Do
c.Value = Sht.Range("A" & Int((20 * Rnd) + 1))
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Lynton" wrote:

In a1:a20 I have numbers 1-20. I need to put these numbers randomly in
columns B to M without any numbers repeating across the rows. Is this
possible?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default generating random numbers without repeats

You may want to visit J.E. McGimpsey's site and grab a copy of his =RandInt()
function.
http://www.mcgimpsey.com/excel/udfs/randint.html

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Lynton wrote:

In a1:a20 I have numbers 1-20. I need to put these numbers randomly in
columns B to M without any numbers repeating across the rows. Is this
possible?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 806
Default generating random numbers without repeats

Hello,

I suggest to use my UDF RandInt:
http://sulprobil.com/html/randint.html

Regards,
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
Generate random numbers 1-100 without any repeats? ExcelFan Excel Worksheet Functions 4 May 5th 23 07:46 PM
Generating random numbers tobbey Excel Worksheet Functions 2 January 5th 10 08:05 AM
Generating Random numbers. Tyler Excel Discussion (Misc queries) 3 September 22nd 07 09:48 PM
Generating random numbers with the occasional outlier [email protected] Excel Worksheet Functions 3 November 5th 06 09:43 PM
Generating Random Number from a set of numbers CalsLib Excel Discussion (Misc queries) 3 March 17th 06 04:27 PM


All times are GMT +1. The time now is 11:51 PM.

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

About Us

"It's about Microsoft Excel"