+ Reply to Thread
Results 1 to 9 of 9

Macro Recalculating List in order to have the always the same sum

  1. #1
    Registered User
    Join Date
    11-07-2012
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    53

    Macro Recalculating List in order to have the always the same sum

    Hello,

    I have the following problem. In excel I have two columns - A and B. Each column has 10 rows with different values. I would like to be able to write a "0" on a random value and then being able to recalculate the values in the column, adding the missing sum to each cell.
    AS IS situation:

    A |B
    10 |20
    10 |30
    20 |40

    When I put 0 in stead of "10" in cell A1, I would like column A to be recalculated as follows:

    A |B
    0 |20
    15 |30
    25 |40

    Any Ideas?

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro Recalculating List in order to have the always the same sum

    Try this:-
    Please Login or Register  to view this content.
    Regrds Mick

  3. #3
    Registered User
    Join Date
    11-07-2012
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Macro Recalculating List in order to have the always the same sum

    Good Work, MickG!

    Now it becomes a little more complicated. The way it works, it only takes into account if one ZERO is put. What should I do, if I want to put "0" in both A1 and A2?
    The idea is that the rest should be evenly distributed. In the bast case scenario I should be able to put 9 times zero and at the end I will have the whole SUM of the column in the tenth cell, where no 0 is present.

    I hope you understand what I mean.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro Recalculating List in order to have the always the same sum

    Try this:-
    Please Login or Register  to view this content.
    Regrds Mick

  5. #5
    Registered User
    Join Date
    11-07-2012
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Macro Recalculating List in order to have the always the same sum

    Works like a charm!
    Indeed!

    Another question? (do not answer me, if you do not want..., you have already helped me a lot )
    What would the model look like if we implement another rule? Let's say we have the following:

    40
    20
    20

    And we decide to delete the 20. With the model now, we would receive:
    50
    0
    30

    What I want, is to receive the following:
    54
    0
    26

    The reason to add 14 to 40 and 6 to 20, is due to the fact, that in the initial values, 40 was twice bigger than 20, so it should get twice more.
    I was able to make a solution like this in Excel, but it uses two additional columns for the calculations.

    Thank you once again! It is really good to see someone who actually understands what is in your head
    Have a nice evening

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro Recalculating List in order to have the always the same sum

    I understand the basic logic , althought 6 & 14 are not strickly proportionate to 40 & 20, so you would need a rule that could be applied to the whole range of numbers, because although you have only ever shown 3 row in your example, you initially spoke about 10 rows and thats what the code was based on.

  7. #7
    Registered User
    Join Date
    11-07-2012
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Macro Recalculating List in order to have the always the same sum

    Yes, exactly. If it would make it easier, consider that you have the sum as value (not as formula) on row 11.

    And to make it even crazier, can you think of a solution with an array?

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro Recalculating List in order to have the always the same sum

    I think you will need to show a Before and After example and explain the logic.

  9. #9
    Registered User
    Join Date
    11-07-2012
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Macro Recalculating List in order to have the always the same sum

    Yes, before and after is a good idea Thus you can always return to the first figures, just by copying them.

    But can you really think of an array solution for this? It would be really crazy.

+ 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. UDF Macro crashing excel while UDF is recalculating
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2012, 08:12 PM
  2. Automated macro won't stop recalculating
    By Stickleback in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2012, 01:16 PM
  3. Recalculating Formulas after Running a Macro
    By hugedomer11 in forum Excel General
    Replies: 2
    Last Post: 08-09-2011, 10:48 AM
  4. purchase order list & order number generator
    By podaf in forum Excel General
    Replies: 2
    Last Post: 06-28-2009, 06:02 PM
  5. [SOLVED] Recalculating Prize List when ties occur
    By elevdown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-31-2008, 03:52 PM

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