Closed Thread
Results 1 to 11 of 11

How to Split a number in one cell evenly over several?

  1. #1
    Registered User
    Join Date
    05-08-2010
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    How to Split a number in one cell evenly over several?

    Hi all,

    Probably a simple little function, help would be appreciated!

    I'd like to take a number entered into one cell ie. A1 = 20

    and split it randomly but evenly over 3 other cells ie.
    B1=6
    C1=8
    D1=6

    Number should be whole and no zeros?

    Thanks all!

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

    Re: How to Split a number in one cell evenly over several?

    Welcome to the forum.

    In B1, =RANDBETWEEN(1, A1-2)

    C1: =RANDBETWEEN(1, A1-B1-1)

    D1: =A1-SUM(B1:C1)
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: How to Split a number in one cell evenly over several?

    Something like this?

    Edit: Ahh, correct shg.. I skip "randomly" part
    Attached Files Attached Files

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

    Re: How to Split a number in one cell evenly over several?

    Thinking about it, this has better statistics:

    B1: =INT(RAND()^2 * (A1-2) + 1)

    C1: =INT(RAND() * (A1-B1-1) + 1)

    D1: =A1-B1-C1

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: How to Split a number in one cell evenly over several?

    That works but it doesn't divide numbers evently (biggest numbers are in first column)...

    I get this one more fairly (at least look for me on first sight)...

    =RANDBETWEEN(1;ROUNDDOWN(($A2+1)/2;0))
    =RANDBETWEEN(1;ROUNDDOWN(($A2-B2-1);0))
    =A2-B2-C2
    Attached Files Attached Files

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: How to Split a number in one cell evenly over several?

    Or maybe this:

    =RANDBETWEEN(SQRT($A2);ROUNDDOWN(($A2)/2;0))
    =RANDBETWEEN(SQRT($A2);ROUNDDOWN(($A2)/2;0))
    =A2-B2-C2
    Attached Files Attached Files

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

    Re: How to Split a number in one cell evenly over several?

    Perfect spectrum

    B1: =MATCH(513*RAND(), {0,54,105,153,198,240,279,315,348,378,405,429,450,468,483,495,504,510})

    C1: =INT(RAND() * (A1-B1-1) + 1)

    D1: D1: =A1-B1-C1

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: How to Split a number in one cell evenly over several?

    Hmmm... I'll need to look little on the numbers (to figure it out ) but, on first sight, I think this is not good either...

    Let say we have 20...

    Randomly and evenly I suppose is (all variations):

    6+6+8
    6+7+7
    6+8+6
    7+6+7
    7+7+6
    7+8+5
    8+6+6
    8+7+5
    8+8+4

    But it depends how low can you go (min is 6 , or 5, or 4 or 3 or less ??)

    Above example is with min 6 and max 8 (not 4 as last example could trick you because 4 is there because of 20 - SUM(randbetween(6,8), randbetween(6,8))...

    Now... obviously, last column has bigger range but also groupped around number 6 (first two has 33% for getting 6,7 or 8 and last column 11% for 8, 22% for 7, 33% for 6, 22% for 5 and 11% for 4 (where 4 and 5 can't appear in first two columns)...

    now... I don't know can this be arranged better but your solution might give, correct me if I'm wrong:
    0, 0, 20
    or
    1,2,17
    but also
    18, 1, 1 etc

    when RAND is nearby 0 or 1...

    Wich won't give evenly distribution...

    Therefore I pick for 20 min and max range 4 (sqrt 20) and 10 (20/2)...

    This also isn't very good (because it can be 10, 10, 0) but I think it's better than just RAND (i.e. 0,0,20)... But it depends on defining range so it can be tuned better (user should specify here what's his expectation)...

    Impatient to hear your answer and ideas

  9. #9
    Registered User
    Join Date
    01-16-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question Expanding on the question..

    To expand on the same question...

    I need to do the same thing but I need to distribute my sum (ex 20) across 12 columns where each column has a different weight (ex .09), still returning integers.

  10. #10
    Registered User
    Join Date
    02-11-2015
    Location
    Amsterdam
    MS-Off Ver
    office 2007
    Posts
    39

    Re: How to Split a number in one cell evenly over several?

    Hey guys,

    I am looking for similar solution (I think). I have posted my thread, but no luck yet, also in other forums. Here are the links to my thread.
    Excelguru
    And in this forum but this is old.

    Any suggestions?

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to Split a number in one cell evenly over several?

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

Closed Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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