+ Reply to Thread
Results 1 to 12 of 12

Select a Random Number within a group and make that selected number unique among groups

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    Indy
    MS-Off Ver
    Excel 2010
    Posts
    6

    Select a Random Number within a group and make that selected number unique among groups

    1) 9 groups of 4 numbers (integers)
    2) Each integer value less that 10
    3) Each number is unique within the group
    4) Multiple Groups can have same number(s) Group A 1,3,7,5 - Group B 2, 5, 8, 9- etc.

    Want to randomly select a number within group of 4
    But each group must have a unique resulting number between the groups.
    (i.e. no group can have the same resulting number)
    Problem_partial_solution.png
    Attached Files Attached Files
    Last edited by cheyennemtnman; 11-18-2019 at 10:51 PM.

  2. #2
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Select a Random Number within a group and make that selected number unique among group

    I need to insert more column/rows and use this formula.

    Please Login or Register  to view this content.
    By the way, it's did not a final result, you may need to re-calc more than one time until got the goal.

    Regards.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,181

    Re: Select a Random Number within a group and make that selected number unique among group

    I think the issue is, based on your rules, you could have data that can't be solved. If you 9 groups and they all have 1,2,3,4 as their 4 numbers (or some other small variations), you won't be able to make all random numbers unique.

  4. #4
    Registered User
    Join Date
    11-28-2012
    Location
    Indy
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Select a Random Number within a group and make that selected number unique among group

    Quote Originally Posted by Gregb11 View Post
    I think the issue is, based on your rules, you could have data that can't be solved. If you 9 groups and they all have 1,2,3,4 as their 4 numbers (or some other small variations), you won't be able to make all random numbers unique.
    Thank you for responding... The groups do not have 1,2,3,4 They will be numbers between 1-9 but only 4 numbers from that set for that group.
    The numbers actually could be names... the randbetween formula selects which of the four will be placed in the cell below the group list.
    What I am looking for I guess is that I need go through the group result and then compare to the already found group result to see if there is
    a duplicate result. If so then take a look at the remaining group items to see if I can place another number that would be unique from the group's list. THen go to the next group and do the same iteration. The resulting row would be numbers 1 - 9 placed in the row each number being used in the row uniquely.

    So maybe I need a help Column or Row to keep track what numbers have already been used...
    Last edited by cheyennemtnman; 11-19-2019 at 12:52 AM.

  5. #5
    Registered User
    Join Date
    11-28-2012
    Location
    Indy
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Select a Random Number within a group and make that selected number unique among group

    Quote Originally Posted by menem View Post
    I need to insert more column/rows and use this formula.

    Please Login or Register  to view this content.
    By the way, it's did not a final result, you may need to re-calc more than one time until got the goal.

    Regards.
    Thank you for responding!
    I will take a look at your If (countif ...) solution and try to figure out the errors and column assignments

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,252

    Re: Select a Random Number within a group and make that selected number unique among group

    Hi,

    See if this result fits your problem. You really don't need the first two steps as all is random. Click the button and get instant answers.

    Rand Result Backwards.xlsm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Registered User
    Join Date
    11-28-2012
    Location
    Indy
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Select a Random Number within a group and make that selected number unique among group

    Thank you for your response. I need the first and second steps... The four numbers in each group are a given in each group.... I have to use those numbers as they are... then I have select one of those numbers randomly in that group. The resulting selected number is one of nine numbers selected... but each need to be unique. It could be names instead of the numbers. The desired result published in my OP is one solution of uniqueness... example. With what I have thus far I could get three 7s or three 5s etc. I need to find a solution that checks to see if a number has been selected already then select one from the remaining possibilities. Hitting Calculate now will change the results but there may not be unique values in the results...

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,252

    Re: Select a Random Number within a group and make that selected number unique among group

    Hi Chey,

    You pick 4 random numbers from 9 and then one random number from 4 of the first pick. You end up wanting a full set of the random numbers. My contention is that you don't need the first two steps. Yep - you heard me right! Make the final answer and work backwards. You asked this question wanting an answer. This is mine.

    Step back and ask yourself, if you pick random numbers 3 times, does it make it more random than picking them once? By putting constraints on your random choices, do they become more or less random? Perhaps this problem is to show you this dilemma.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Select a Random Number within a group and make that selected number unique among group

    Try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It only works because of the distribution of the numbers throughout the sample. With any other combination I doubt it will work. It's a bit of a "cheat" alternating Min/Max numbers in the resulting arrays. The 9th column caused me fits. All the numbers were already used and all that was needed was a 1. There are no 1s in the 9th column.


    B
    C
    D
    E
    F
    G
    H
    I
    J
    2
    A
    B
    C
    D
    E
    F
    G
    H
    I
    3
    6
    6
    6
    1
    2
    1
    1
    9
    4
    4
    7
    3
    9
    7
    3
    9
    5
    4
    8
    5
    5
    4
    5
    5
    8
    8
    4
    2
    2
    6
    8
    7
    7
    9
    9
    2
    3
    6
    3
    7
    8
    7
    7
    5
    1
    3
    8
    4
    2
    4
    9
    10
    5
    7
    6
    9
    2
    8
    1
    4
    3
    Dave

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Select a Random Number within a group and make that selected number unique among group

    This formula is a little shorter. Same issues, same results.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,181

    Re: Select a Random Number within a group and make that selected number unique among group

    Marvin, in your solution, it looks like the random number selected at the bottom of the column is not within the numbers above it which is what he wants.

    Chey, what if you come up to a column where all 4 numbers have already been used as random numbers in the columns before it? Are you expecting it to go back to the previous columns and select different numbers until it finds a solution where all are unique?

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,252

    Re: Select a Random Number within a group and make that selected number unique among group

    Hey Gregb,

    I agree that many times we get problems that have no solution or the method is "obscure". My point is that 3 levels of random numbers are just as random as one level of random numbers. I believe Dave found there is no solution after going through Chey's "method". If you need to change the random numbers to get from step 1 to 2, so they can get to step 3, why didn't he simply start with the final answer. My question is: Are 3 levels of random numbers better than one? Isn't that the point of "Random" numbers?

+ 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. Replies: 1
    Last Post: 06-04-2019, 03:46 PM
  2. [SOLVED] Generate random combinations only one number from each group of 4 letters
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 08-18-2018, 12:01 PM
  3. Replies: 1
    Last Post: 10-19-2016, 12:22 PM
  4. random number for group
    By mohdmizi in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-19-2014, 06:52 AM
  5. Need forumla to sum number of unique values in groups of different sizes
    By ea2146 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-30-2013, 02:33 PM
  6. [SOLVED] Generating unique random number
    By Fuhgawz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-09-2012, 05:26 PM
  7. Replies: 6
    Last Post: 06-03-2010, 04:25 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