+ Reply to Thread
Results 1 to 28 of 28

Excel Formula to Adjust certain rows to give a resulting reference cell

  1. #1
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Post Excel Formula to Adjust certain rows to give a resulting reference cell

    Please help me with issue which I am trying to figure out.

    I want the sum of a particular cells to be equal to a reference cell. i.e if the sum of the cells is greater than the reference cell, the cell in which the sum exceeds should automatically adjust in order to give the result of reference cell.

    Please find the attachment to get the idea clear

    Thanks in Advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    You can't have a value and a formula in the same cell. This formula, in D3, copied across, does what you wanted:

    =IF(IF(SUM($D$2:D2)>=$B$2,D2-(SUM($D$2:D2)-1000),SUM($D$2:D2))<=0,"",IF(SUM($D$2:D2)>=$B$2,D2-(SUM($D$2:D2)-1000),SUM($D$2:D2)))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Thank You for the quick assistance. I would be highly grateful if Glenn could please explain the logic behind the formula and also when I drag the formula other cells are getting added. Is it possible to make them as it is and only change the cell which exceeds the sum ?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Yep. My mistake. Corrected (if I understand your requirement.
    =IF(IF(SUM($D$2:D2)>=$B$2,D2-(SUM($D$2:D2)-1000),SUM($D$2:D2))<=0,"",IF(SUM($D$2:D2)>=$B$2,D2-(SUM($D$2:D2)-1000),D2))

    Let me know if this is correct...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Thanks Glenn. This was my requirement. But is it possible to get the result in a single cell showing the adjusted amount only without dragging it horizontally.

    Thank you so much. But could you please explain me the logic so that I can understand better.
    Last edited by elaph; 11-26-2016 at 12:08 PM.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I'll explain the logic when it's finished. No point yet. A picture is worth a 1000 words. If this is not what you want, please explain by posting a sheet showing what you REALLY want. I'm not prepared to keep guessing forever!!!

    However, you do need a formula in every cell - as you cannot tell a priori which cell will need to be adjusted.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Please find the attached excel file for clarity.
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    This monster will do it. However, how will you be able to tell WHICH value is the subject of the adjustment, in this case???
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    There no best description for you other than MONSTER. Awesome !!!. I have mentioned the needful in the file. Please find the excel file again.

    THANKS A TON for HELPING
    Attached Files Attached Files

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I don't think that you can have the very last part. However, I can get the adjusted amount in red font.

    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Okay, Thank You so much. Could you please spare the time to explain the logic to me if possible. However I am marking the thread "Solved" and will add reputation.

    Thank you MONSTER.

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I've spent much of the day working a chainsaw and I'm tired. I'll have a reply for you in the UK morning.

  13. #13
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Sure Glenn. No issues.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    In the cold light of morning... there's an easier way to do this. Newdoverman suggested one simplification, but this is simpler still.

    The formula is split up into 4 similar units, one for each of the cells in D to F the result from each unit is added together to give a final result.. The first unit considers D2, the second considers the sum of D2+E2, the third considers the sum of D2+E2+F2, etc.

    Just look at the first line in the formula:

    IF(SUM($D$2:D2)>$B$2,IF(D2-(SUM($D$2:D2)-$B$2)<0,0,D2-(SUM($D$2:D2)-$B$2)),0)

    IF(SUM($D$2:D2) IF the running total

    >$B$2 is greater than the target value ...

    IF(D2-(SUM($D$2:D2)-$B$2) IF the running total minus the target, subtracted from the value in the first cell

    <0,0 is less than zero, return zero, otherwise...

    D2-(SUM($D$2:D2)-$B$2)) return D2 minus the difference between the running total and the target. however, (back to the beginning of the formula again)

    IF(SUM($D$2:D2)>$B$2,things that happen if this is TRUE,0) If the running total is NOT greater than the target value, return zero.

    Same for each of the 4 units in the formula.

    I have amended the CF with the simpler formula. i also added in a bit more CF to grey-shade those cells AFTER the adjusted cell.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Thanks Glenn. So two sets of formulas are used to get the derived output right. One for the adjusted cell and another in the CF.

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Nine formulae, actually. One monster for the result cell and two CF formulae in EACH of the 4 cells to deliver the red font or grey shading.

  17. #17
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Dear Glenn, For the cell alone in D2 if I insert amount greater than 1000, will it be able to adjust the difference. Please find the excel file.
    Attached Files Attached Files

  18. #18
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I do not understand your comment. As far as I am concerned, it is giving the correct result. 1000 in J2. What were you hoping to see and where?

  19. #19
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I am sorry. It was a mistake from my side. But do we need to make the cell reference by inserting $ sign ?

  20. #20
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Home/Number/Accounting Number format and select dollars.

  21. #21
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    I was not mentioning about the currency. The sign which you have used to make the cell reference. It is not needed right, as we want to drag the cells downwards.

  22. #22
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Another change of requirement!!

    Do the new rows refer to the same cell (B2) or to B3, B4, etc, as you copy down?

  23. #23
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Another change of requirement!!

    Do the new rows refer to the same cell (B2) or to B3, B4, etc, as you copy down?

  24. #24
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    please find the attachment.
    Attached Files Attached Files

  25. #25
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    Can you populate one or two more rows with your expected answers?

    MORE IMPORTANTLY: are there any further surprise requirements that you have hidden away somewhere?????

  26. #26
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    No reply as yet. So.. I'll have a LAST guess.
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    HAHAHA. No Glenn. This was my ONLY requirement but it is very difficult to figure this out but you did it.

    Please find the attachment.
    Attached Files Attached Files

  28. #28
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,101

    Re: Excel Formula to Adjust certain rows to give a resulting reference cell

    So, that is what my attachment at Post 26 does. hopefully the problem IS now solved....

+ 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. [SOLVED] IF formula to give cell reference?
    By nimv1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-07-2016, 04:47 AM
  2. [SOLVED] Formula/Macro to give active cell reference in cell
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-23-2014, 03:36 AM
  3. [SOLVED] How to replace a function with its resulting reference in a formula?
    By Dmitry Kopnichev in forum Excel General
    Replies: 7
    Last Post: 10-13-2005, 05:05 PM
  4. How to replace a function with its resulting reference in a formula?
    By Dmitry Kopnichev in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-13-2005, 05:05 PM
  5. [SOLVED] How to replace a function with its resulting reference in a formula?
    By Dmitry Kopnichev in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-13-2005, 05:05 PM
  6. Replies: 2
    Last Post: 06-03-2005, 07:05 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