+ Reply to Thread
Results 1 to 29 of 29

Need help: Difference between sum of values with data in one column with adjacent column

  1. #1
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Need help: Difference between sum of values with data in one column with adjacent column

    Hi All,

    I have two columns A and B as shown below with 12 values(A1-A12 and B1-B12)

    Please Login or Register  to view this content.
    Now In A14 i need a formula, which will

    1. Get the sum of cell values in Column B and Sum of Corresponding cell values in Column A
    Column B = 21.0+22.5+23.0 = 66.5
    Column A = 20.0+20.0+20.0 = 60.0
    2. Check if Sum in Column B is Greater than that of Column A
    a)If yes then take the difference --> Lets take this as X = 66.5 - 60.0 = 6.5
    b)If it is equal or less then take it as X= 0.
    3. Get the sum of all values in Column A -- > Lets take it as Y = 223.0
    4. Now the result will be X+Y = 6.5+223.0 = 229.5

    Please help me in getting this done.. Let me know if you could not understand my requirement.

    Thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Please Login or Register  to view this content.
    Last edited by haripopuri; 02-27-2013 at 05:44 AM.

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Please describe these parts in a clear way.......

    a)If yes then take the difference --> Lets take this as X = 66.5 - 60.0 = 6.5
    b)If it is equal or less then take it as X= 0.
    3. Get the sum of all values in Column A -- > Lets take it as Y = 223.0
    4. Now the result will be X+Y = 6.5+223.0 = 229.5


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by haripopuri View Post
    Please Login or Register  to view this content.
    Looks like you have hardcoded b1:b3 and A1:A3.. but it should not be the case..

    next time someone may enter value in B4(u can enter value till B12)

    So if value is there in B4 then you have to sum B1,B2,B3,B4 and then A1-A4 then check which is greater and so on..

    so ultimately you need to SUM all available values in column b and corresponding values in Column A..then need to do the other tasks.. pls help

  5. #5
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    You were supposed to ask exactly what you need in the question above.

  6. #6
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Please describe these parts in a clear way.......

    a)If yes then take the difference --> Lets take this as X = 66.5 - 60.0 = 6.5
    b)If it is equal or less then take it as X= 0.
    3. Get the sum of all values in Column A -- > Lets take it as Y = 223.0
    4. Now the result will be X+Y = 6.5+223.0 = 229.5
    I hope you are clear with the first point which says get the sum of all existing values in column B and then sum of corresponding values in column B.

    2. Now 2nd point says that, if sum taken from column B is greater than that of column A then take the difference.
    3. Now add all the values in column A.
    4. To this value(value from 3rd point) add the value got in 2nd point

    I hope u are clear now

  7. #7
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by haripopuri View Post
    You were supposed to ask exactly what you need in the question above.
    Sorry for not clear with my question..

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Try this........

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Try this........

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    dont know if i am missing something.. it is returning 0.0 for me

  10. #10
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Please Login or Register  to view this content.
    this part is summing up all the values in column A instead corresponding values!

  11. #11
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Oops....... Minor changes in formula, try this...

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Oops....... Minor changes in formula, try this...

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Same again.. getting 0.0 as result

  13. #13
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Its working fine for me... please attach a sample file for review

  14. #14
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Its working fine for me... please attach a sample file for review
    Ok sample file i ll attach after 1 or 2 hr time.. my cab driver is waiting for me n need to move.. sorry for the delay and thanks for helping me

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    But I will not be available in online after a hour time for next 12 hrs.. So I am attaching my working file for your reference
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    But I will not be available in online after a hour time for next 12 hrs.. So I am attaching my working file for your reference
    Hey,

    Your code is working for me in my test excel file but not in my Project file.. The only difference in my test and project file is, in test file the values in column A and B are entered manually where as in my project file, it is driven by a formula.. does this cause any problem??

    The below code worked in my project file so as of now the problem is resolved..
    Please Login or Register  to view this content.
    Thanks a lot for your help I will come up with more question when in doubt

    Thank you,.

  17. #17
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    in my project file, it is driven by a formula.. does this cause any problem??
    No, not at all......

    Glad you solved it on your own

  18. #18
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Hi,

    There is some problem with your formula as well as the formula which i gave...

    the problem is:

    when a cell value in column B is less than the corresponding value in column A, we need to ignore that and sum up only the other values!

    i was wrong in my requirement earlier...

    could you please help me in that..?

    Thank you.

  19. #19
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    sum up only the other values
    Please describe the above quote little bit in brief for better understating

  20. #20
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Please describe the above quote little bit in brief for better understating
    Ok.. here goes an example

    Please Login or Register  to view this content.
    in this example.. you can see that B4 is 18 which is less than A4 which is 20. same for B6 and A6

    Since B4<A4 and B6<A6, i need to ignore these values..

    now sum all other values in column B.. i,e: B1+B2+B3+b5
    sum the corresponding values in column A i,e: A1+A2+A3+A5

    take the difference between the above 2 i,e: (B1+B2+B3+B5) - (A1+A2+A3+A5)

    Now the final result will be SUM(A1:A12) + (B1+B2+B3+B5) - (A1+A2+A3+A5)

    I hope it is clear now..

  21. #21
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Try this...........

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Try this...........

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    i really dont understand why your formula is not working in my porject.. it is working fine in my test file where the result should come as 229 and it is giving 229..

    but in my project, same data is giving 63 as result instead of 229.. i guess there will be some issue if the cell values are populated using formula!!

  23. #23
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    In your project file check whether the values are entered as text

  24. #24
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    In your project file check whether the values are entered as text
    i guess it is stored as numbers only.. between how can i check that

  25. #25
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Not sure whether you applied any alignment Left,Rgiht or center to that column if no alignment is applied then the real numbers will always stay in the right side of the cell. If anything stays in the left side of the cell then it's text formatted number or text characters are getting included with it.

    Please check and confirm

  26. #26
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Hey check the sample file which i have uploaded here.. now i have copied values from my project file to here and i could notice that result coming here is not correct.. but the same values if you type it in another sheet and use the same formula it works great..!
    Attached Files Attached Files

  27. #27
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Hm... Try this revised formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  28. #28
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Quote Originally Posted by :) Sixthsense :) View Post
    Hm... Try this revised formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    cool.. this is working

  29. #29
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Need help: Difference between sum of values with data in one column with adjacent colu

    Glad it works for you

+ 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