+ Reply to Thread
Results 1 to 5 of 5

Find Array that corresponds to certain totals

  1. #1
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Find Array that corresponds to certain totals

    Good day,

    A guy called Razvan posted a reply on Stack Overflow on 14th Feb 2014, showing how random numbers could be generated which would sum to a specified total . I was wondering however if this could be taken two steps further. In my attachment I have in the grey area Razvan's part. The random numbers will always tally up to 1000 in this case. To the right of that are my additions. Would it be possible either by code or formulae, (I would guess code) to have just one set of numbers generate, then have the code looking at E22 and compare the difference between E22 and the desired figure, which is in G1, determine the best possible place in columns B and C (or B or C),to make adjustments (By calculations), then make the adjustment, and then step 2, to compare cells F22 with H1 and do the same adjustments. IMPORTANT: The second adjustment should be made looking at columns C and E or (C only or E only). Please try and help, this is for a major project I need to get done in the course of about one week...I really appreciate and rate your assistance very highly on this one. Even if we could get the first calculation part going, it would already be a fantastic start.
    Attached Files Attached Files

  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: Find Array that corresponds to certain totals

    ..........
    Last edited by shg; 01-11-2015 at 06:36 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    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: Find Array that corresponds to certain totals

    Maybe this:

    Row\Col
    A
    B
    C
    D
    E
    1
    Target
    2
    2100
    C2: Input
    3
    Multiplier
    Rand()
    Values
    4
    0.05
    0.4432
    42.8554
    A4 and down: Input
    5
    0.10
    0.4904
    47.4161
    B4 and down: =RAND()
    6
    0.15
    0.7018
    67.8579
    C4 and down: =B4*$C$2/$B$22
    7
    0.25
    0.6865
    66.3787
    8
    0.50
    0.8773
    84.8317
    9
    0.75
    0.1291
    12.4859
    10
    1.00
    0.6906
    66.7796
    11
    1.25
    0.9668
    93.4825
    12
    1.50
    0.8985
    86.8781
    13
    2.00
    0.9568
    92.5139
    14
    2.25
    0.0494
    4.7794
    15
    2.50
    0.9984
    96.5390
    16
    3.00
    0.1624
    15.7062
    17
    3.75
    0.1125
    10.8786
    18
    5.00
    0.8237
    79.6494
    19
    7.50
    0.8259
    79.8585
    20
    10.00
    0.1845
    17.8384
    21
    22
    21.7178
    2100.0000
    B22 and across: =SUMPRODUCT($A4:$A20, B4:B20)


    The numbers generated by Razvan's method have an odd distribution, though; more mid-size numbers than the Dirichlet distribution that occurs with string cutting*, as a result of dividing the numbers by their sum to normalize them. It's not obvious to me how to apply string-cutting to achieve a desired weighted sum, though.

    * For n numbers totaling t, cut a piece of string of length t in n-1 random places. The resulting lengths are the numbers.
    Last edited by shg; 01-10-2015 at 01:31 PM.

  4. #4
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Find Array that corresponds to certain totals

    Thank you so much shg!, your code is working great!. Thank you very very much!!

  5. #5
    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: Find Array that corresponds to certain totals

    You're welcome.

+ 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. Daily totals using an array & SumIfs
    By jginrey in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-13-2014, 03:10 PM
  2. Combine totals in a array/string then delete duplicate row
    By RobertOHare in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2013, 09:46 AM
  3. Find a value in an array and return multiple values in an adjacent array
    By tonbra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2012, 08:35 PM
  4. Find Totals and copy the whole row
    By corchox in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2011, 05:19 PM
  5. How do find Median of a set of totals and find the relating grade
    By whitespaces in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-12-2006, 11:16 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