+ Reply to Thread
Results 1 to 3 of 3

randbetween different than

  1. #1
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2007
    Posts
    185

    randbetween different than

    Hi Guys,

    I was trying to put a formula down to give me in one line of six cells a random number between a range of numbers (the same range for all cells) but in each cell the number to be different than in the others.

    So if the range would be 1-99 then let me say:

    5 66 24 ...

    I have tried for the first cell:
    Please Login or Register  to view this content.
    for the next one I tried:
    Please Login or Register  to view this content.
    hoping that it will exclude the previous result.

    Even when living a static value in cell one the cell two came back occassionaly with the same number.

    Would anyone of you know if there is an alteration to that formula that I can use ar maybe a macro with connection to some formula to live values only when all the numbers deffire from each other?

    I know how to make macro for values only but only bassed on selection / copy / paste special / values only. Don't know if there is a way to give conditions to copy.

    Thanks for reading and giving it a go.
    Last edited by Ramzes; 02-16-2011 at 10:04 AM. Reason: Changing Prefix
    ...and this is when I walk in, dressed fully in white...

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: randbetween different than

    Here is one way


    First, ensure cell A1 is empty and
    Excel 2003: goto Tools>Options and on the Calculation tab
    Excel 2007: goto Excel Options>Formulas>Calculation Options
    check the Iteration checkbox to stop the Circular Reference message.

    Next, type this formula into cell A2
    =IF(($A$1="")+(AND(A2>0,COUNTIF($A$2:$F$2,A2)=1)),A2,RANDBETWEEN(1,99))
    it should show a 0

    Copy A2 down to F2.

    Finally, put some value in A1, say an 'x', and all the random numbers will
    be generated, and they won't change.

    To force a re-calculation, clear cell A1, edit cell A2, don't change it,
    just edit to reset to 0, copy A2 down to F2, and re-input A1.

  3. #3
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2007
    Posts
    185

    Re: randbetween different than

    Thank you for your help Bob Phillips.

    It works perfectly.

    Thanks again
    Simon

+ 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