+ Reply to Thread
Results 1 to 3 of 3

Unique random numbers

  1. #1
    Registered User
    Join Date
    01-28-2012
    Location
    SoCal
    MS-Off Ver
    Excel 2003
    Posts
    2

    Unique random numbers

    Hi
    I have two side by side excel cells, let's call them cell A1 and cell B1. In these two cells I have random numbers rounded off to be integers with the command INT(Rand() * 10). What I'd like to avoid is both A1 and B1 having the same number. I am simulating the score of a game of two teams and do not want ties. What can I do to make sure that the two cells do not have the same value? Ideally I'd like cell B1 to pick a new random number if it has the same value as A1.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Unique random numbers

    Welcome to the forum.

    In A1: =RANDBETWEEN(0,9)

    In B1: =MOD(A1+RANDBETWEEN(1,9), 10)
    Last edited by shg; 01-28-2012 at 03:40 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Unique random numbers

    a1 =RANDBETWEEN(0,10)
    a2 =IF(A1=0,RANDBETWEEN(1,10),CHOOSE(RANDBETWEEN(1,2),IF(A1=1,RANDBETWEEN(2,10),RANDBETWEEN(1,A1-1)),IF(A1=10,RANDBETWEEN(1,9),RANDBETWEEN(A1+1,10))))
    mind you seeing shgs above reminds ne weve both been down this road before only i couldnt remember!
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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