+ Reply to Thread
Results 1 to 9 of 9

Thread: 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 Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    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)
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    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
    "Relax. What is mind? No matter. What is matter? Never mind!"

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

    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
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    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
    "Relax. What is mind? No matter. What is matter? Never mind!"

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    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
    "Relax. What is mind? No matter. What is matter? Never mind!"

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

    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
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    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
    "Relax. What is mind? No matter. What is matter? Never mind!"

  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.

+ Reply to 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.2.0