+ Reply to Thread
Results 1 to 12 of 12

Balanced Sum

Hybrid View

  1. #1
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Balanced Sum

    Hello, I am trying to program a balanced sum into Excel and am coming across some difficulty. I'm hoping someone can help me.
    Here is what I'm trying to do: I have a list of numbers that should always equal a set sum (for example, ten). If I increase one of the numbers, I want the others to all decrease proportionately so that the sum stays the same. So, for example, if the balanced sum is ten and there are ten numbers in the list, they should all start of as equaling 1. However, if I increase one of the cells to 2, then the others should all decrease to 8/9 so that the sum stays 10. The difficulty I'm finding is that each cell needs to be a variable in a sort of way.

    Thank you very much.

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

    Re: Balanced Sum

    you'd need vba and mac 2008 doesnt support it,
    "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

  3. #3
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    There has to be some way I can do this. Can anyone help? Is there another version of excel I can use on my mac that can do this?
    Last edited by defeater; 12-11-2011 at 04:31 PM.

  4. #4
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    There has to be some way I can do this. Can anyone help? Or is there any form of excel I can download for my macbook pro that can do this?

  5. #5
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    Sorry, I accidentally posted the same thing twice.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Balanced Sum

    Hi defeater,

    Read about the newer version of Excel for the Mac at http://www.macworld.com/article/1551...el2011faq.html
    I believe this has Macros and uses VBA to accomplish what you are trying to do.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    okay great. I have a copy of that. So can anyone tell me how to do it with office 2011? Thanks

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Balanced Sum

    OK defeater,
    Find the attached that does what you request. You will need to find the VBA code behind the worksheet to see how it works.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    Gosh, I've spent like three hours trying to do that on 08, so it looks so beautiful on my 2011! hahahahaha. But 2 questions, if you'd be so helpful. 1) How did you do that? 2) Is there anyway that I can adjust it to where I can edit any amount of numbers and the rest adjust? For example, I adjust two cells to equal 3 and the other 8 adjust themselves to balance the sum. Thank you so much.

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Balanced Sum

    Hi defeater,
    When Martin said in post #2, you need VBA to do that, he was correct. Just having 2011 Mac version of Excel was a start as it has VBA while 2008 does not. As I wrote the code I knew you would have problems understanding what was happening. You need to learn some VBA. Look behind the worksheet (not in a module) to see the code that does your problem. Here is the topic list for understanding how the problem was done.

    1. Named Ranges (I used NumberRng) in the VBA code.
    2. Events in VBA (I used a Change event so when you changed a number the code would be run)
    3. If Then statements in VBA (I used the If Not Intersect ....)
    4. Intersection of Ranges (Used in #3 above)
    5. For Next Loops in VBA (Used to calculate and fill in the other non input numbers)
    6. Application.EnableEvents to not go into an endless loop in VBA when it calculated the remaning numbers
    7. Passing parameters to Event code (Used with the Target variable passed by Value, not by Ref)

    I could go on but the bottom line is you need to know a lot of stuff to do what you want. As the problem changes you need to see what part of the code needs changing or develope a new plan to solve the problem. You asked a problem that needs your learning to solve. If you really want to get your answer and modify it, start learning the above.

  11. #11
    Registered User
    Join Date
    12-11-2011
    Location
    Las Vegas
    MS-Off Ver
    Mac Excel 2008
    Posts
    7

    Re: Balanced Sum

    Okay. How would you suggest I learn VBA? And lastly, when you say "look behind the worksheet (not in a module) to see the code that does your problem," I'm still not sure how to find it. Sorry, I just don't know much about excel yet.

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Balanced Sum

    Hi defeater,

    The point was you need to learn lots more to attack your problem. Start by going through http://www.excel-vba.com/excel-vba-contents.htm

    To see the VBA window try Alt-F11 (sorry, I don't know how to get there using the Mac 2011 version).

    I wanted to show you that your question had an answer that worked. The problem is that you need to get better at Excel and VBA to understand or do the answer yourself. Hopefully in giving you the code (if you can find it) will show you things your need to learn.

+ 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