+ Reply to Thread
Results 1 to 8 of 8

Preventing duplicate random gen

  1. #1
    Registered User
    Join Date
    01-29-2014
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Lightbulb Preventing duplicate random gen

    I have a spreadsheet I'm using to select questions at random from a chapter in a question bank for a topic I'm studying. It picks the questions proportionately depending on how many questions are in each chapter. But sometimes it returns a duplicate question in a chapter, which isn't that useful.

    Does anyone know how I can prevent this? (See attached)
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Preventing duplicate random gen

    Rand() and RandBetween() both will produce duplicates

    Go for someother UDF approach to eliminate the duplicates


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,663

    Re: Preventing duplicate random gen

    Take a look at this sample to get unique numbers
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  4. #4
    Registered User
    Join Date
    01-29-2014
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Preventing duplicate random gen

    Thanks, I got it to work using the method popipipo described.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Preventing duplicate random gen

    Quote Originally Posted by :) Sixthsense :) View Post
    Rand() and RandBetween() both will produce duplicates
    In theory, it is possible for RAND() to generate duplicates.

    However, in reality what are the odds of that happening?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Preventing duplicate random gen

    Quote Originally Posted by Tony Valko View Post
    in reality what are the odds of that happening?
    May be the below link answer your above quoted question I believe

    I am sure you might have seen that thread when the question was posted and discussed since it has been asked in the Old Microsoft Discussion Group

    https://groups.google.com/forum/#!to...ns/UJzzhwl8M-E

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Preventing duplicate random gen

    Hmmm...

    I don't recall that thread.

    Which post answers the question?

    I've asked this question in the MS MVP forum and no one knows for sure but we all agree that it's a very big number.

    Consider this...

    RAND returns a number with 15 digits. If we need 1000 RAND functions what are the odds that any 2 of those numbers will be exactly the same 15 digits?

    Theoretically, it's possible but the odds of duplicates are very, very slim.

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Preventing duplicate random gen

    After doing several testing I realised that what you have said is true

    I was in an impression that Rand functions will always produce duplicate (I have not tested it earlier which I done now) because most of the members (even some legends) have already mentioned in many posts that it will create duplicate, so myself too blindly accepted / suggested the same not only with this thread in many of the other threads too... lol

    I apologize for giving such a wrong statement and thanks a lot for the correction too

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Preventing duplicate random gen

    No need to apologize.

    Thanks for the feedback!

+ 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. Random numbers from diferent segments and preventing duplicates ??
    By Boblebad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2013, 10:21 AM
  2. preventing duplicate random numbers
    By andy1510 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2010, 09:11 AM
  3. Preventing duplicate row entries
    By kennethchu604 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2009, 07:10 PM
  4. Preventing duplicate entries
    By Ltat42a in forum Excel General
    Replies: 9
    Last Post: 06-14-2008, 08:55 AM
  5. Preventing Duplicate entries
    By Dave32 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-14-2008, 09:51 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