+ Reply to Thread
Results 1 to 10 of 10

Random generator for 6 cols .

  1. #1
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    Ms Office 2016
    Posts
    455

    Lightbulb Random generator for 6 cols .

    Hello all,

    I am wanting to get a macro that can give 6 x random generated numbers based only on the numbers from cols B to G.

    Results to go into cols H to M.

    I know that there are many different combinations, and I don't know what limit is possible as to how many results can be produced.

    Example in row 2.

    Thanks.
    Attached Files Attached Files
    I am grateful for all answers to my questions .
    Also i give a reputation even if not answered .

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Random generator for 6 cols .

    when you say "based only on the numbers from cols B to G" what exactly do you mean? From the examples given all of the random values are equal or above the relevant column in B-G, is that what you mean?
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Random generator for 6 cols .

    I don't understand exactly what you want, but here's a guess.

    This solution generates every time you click on F9, 6 different random numbers chosen from the numbers in B2:F6.

    Please
    try in A8 and copyright until Y8 (exact 25 times)
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    try in A9 and confirm with CTRL+SHIFT+ENTER if necessary:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    try in G2 and confirm with CTRL+SHIFT+ENTER if necessary:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Is this something in the direction you are looking for?
    I look forward to your feedback.
    Attached Files Attached Files
    Last edited by HansDouwe; 09-02-2022 at 06:16 AM.

  4. #4
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    Ms Office 2016
    Posts
    455

    Re: Random generator for 6 cols .

    Only generate from the numbers I have in range B2:G6

    If as example there were only 2 rows of numbers
    7 13 21 27 31 34
    10 16 24 30 34 37

    Then generator would only use these 2 x rows . yes there are two numbers the same being 34 but this could only be selected once to give 6 numbers as a result .
    Thanks .

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Random generator for 6 cols .

    Thx for your feedback.
    Indeed, this random generator only picks numbers from your specified card with 25 numbers.
    And after each draw of six numbers, the drawn numbers are thrown back.
    There will never be duplicates in 1 row of six numbers.
    But in different rows there can be duplicates. Is that exactly what it means?
    If not then let me know.

    Otherwise if you are satisfied with this answer, please consider adding reputation to any helpers you think have earned.

  6. #6
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    Ms Office 2016
    Posts
    455

    Re: Random generator for 6 cols .

    Yes, it's certainly producing 6 random numbers, let me test things out. Will come back to advise.
    Thanks

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Random generator for 6 cols .

    Try this in H2:

    =AGGREGATE(14,6,B$2:B$6,RANDBETWEEN(1,5))

    in I2:

    =AGGREGATE(14,6,C$2:C$6/(COUNTIF($H2:H2,C$2:C$6)=0),RANDBETWEEN(1,5-SUMPRODUCT(COUNTIF($H2:H2,C$2:C$6))))

  8. #8
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Random generator for 6 cols .

    With a macro:
    This way you don't have issues with automatic calculations of rand()

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Random generator for 6 cols .

    from a newbie :D

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    Ms Office 2016
    Posts
    455

    Re: Random generator for 6 cols .

    Thanks to all, many great answers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Random number generator not always generating random numbers
    By Murman01 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-03-2021, 05:29 PM
  2. Replies: 6
    Last Post: 02-20-2019, 12:47 AM
  3. Random Name generator VBA
    By poppeters in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2015, 09:13 PM
  4. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  5. VBA Random Generator
    By switm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2011, 02:22 PM
  6. random name generator
    By SRussell in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-25-2007, 06:28 PM
  7. Random Name Generator
    By Smeeg in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-03-2006, 11:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1