+ Reply to Thread
Results 1 to 30 of 30

Sum calculation

Hybrid View

  1. #1
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Sum calculation

    Hi,

    I want to make a running total of various different things with various amounts.

    So In cell A1 I will have a name (company 1) and B1 I will have an amount (£1).
    In A2 I will have a different name (company 2) and B2 an amount (£1).
    A3 (company 3) B3 (£2)
    A4 (company 1) B4 (£3)
    A5 (company 3) B5 (£7)
    A6 (company 2) B6 (£9)

    and so on.

    What formula can I use so I can add all B cell £ amounts that relate to one company? (company 1 for example)
    so if A = company 1 add B1 + B4
    A = company 2 add B2 + B6
    A = company 3 add B3 + B5

    etc.

    I will have various companies and multiple amounts and want a single total for each company.

    Thanks
    Kirsten

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,422

    Re: Sum calculation

    You would use SUMIF to do that, like this:

    =SUMIF(A:A,"company 1",B:B)

    If you had the list of companies in another set of cells (e.g. in column D), then you could use this in E1:

    =SUMIF(A:A,D1,B:B)

    then copy down to produce a summary table.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi Pete,

    That first formula works great, just what I needed.

    Thanks

    Kirsten

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,422

    Re: Sum calculation

    Glad to help, Kirsten, and thanks for marking the thread as Solved.

    You might also like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  5. #5
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Thanks Pete, I'll Pop a star in.

    One more question, if I can? If I want to add another column of £ so B:B + D:D for example how would I do that? I tried =SUMIF(A:A,"company 1",B:B+D:D)

    Thanks
    Kirsten

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Like this:

    =SUMIF(A:A,"company 1",B:B)+SUMIF(A:A,"company 1",D:D)

    or this might work (try it - let me know):

    =SUMPRODUCT((A:A="company 1")*(B:B+D:D))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi Ali,

    Thanks for that.

    =SUMIF(A:A,"company 1",B:B)+SUMIF(A:A,"company 1",D:D) is giving me the incorrect value. It seems to be just adding the top cell in column D.

    =SUMPRODUCT((A:A="company 1")*(B:B+D:D)) comes up as a value error.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    OK - provide a sample workbook. The first option should definitely work.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Both work for me:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    company 1
    6
    4
    5
    22
    6+5+8+3
    22
    =SUMIF(A:A,"company 1",B:B)+SUMIF(A:A,"company 1",D:D)
    2
    company 2
    8
    2
    8
    22
    =SUMPRODUCT((A:A="company 1")*(B:B+D:D))
    3
    company 3
    3
    8
    8
    4
    company 4
    3
    8
    8
    5
    company 5
    4
    2
    10
    6
    company 6
    5
    6
    9
    7
    company 7
    8
    3
    7
    8
    company 8
    4
    5
    4
    9
    company 9
    7
    8
    10
    10
    company 1
    8
    2
    3
    11
    company 2
    9
    9
    4
    12
    company 3
    5
    9
    1
    13
    company 4
    4
    3
    5
    14
    company 5
    8
    10
    4
    15
    company 6
    7
    4
    9
    16
    company 7
    3
    7
    9
    17
    company 8
    1
    9
    2
    18
    company 9
    8
    3
    3
    Sheet: Sheet1

    I wonder if you have anything other than numbers in either sum column?

    As I said, provide a sample workbook that shows the problem.
    Attached Files Attached Files
    Last edited by AliGW; 07-12-2024 at 02:35 AM. Reason: Workbook added.

  10. #10
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Thanks

    Just working out how to send you a sample work book.

    I do have headings in my B and D columns but it wasn't a problem when calculating the B column. I will remove the headings and see if that solves the problem.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Headings will be problematic with full column references.

    Try these instead:

    =SUMIF(A2:A1000,"company 1",B2:B1000)+SUMIF(A2:A1000,"company 1",D2:D1000)

    =SUMPRODUCT((A2:A1000="company 1")*(B2:B1000+D2:D1000))

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Last edited by AliGW; 07-12-2024 at 02:40 AM.

  12. #12
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    That didn't help. I have some cells in my D column that are blank, I've tried adding a value of £0 or £1 but that didn't help either. My B and D columns are on different pages, will that make a difference to the formula?

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    You need to provide a workbook - the fault lies with your data, and I can't see it. Please see post #11.

    My B and D columns are on different pages, will that make a difference to the formula?
    This is an ENTIRELY different proposition! Need the workbook.

  14. #14
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Ah Ok.

    Just doing a sample workbook now. will post it asap.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Great - thanks.

    Entries like £1 won't add up - if you want to add the pound sign, it should be done via currency formatting.

  16. #16
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi, yes sorry that's what I did.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Still waiting for a workbook ... Nothing to be done until you provide one, sorry.

  18. #18
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    sorry it took me a wee while to get a sample one sorted. posting now.
    Attached Files Attached Files

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    Sorry - I'm confused. What's not working??? Where sre your expected results? What does REQ mean?

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    =SUMIF(Sheet1!C:C,"company 1",Sheet1!M:M)+SUMIF(Sheet1!C:C,"company 1",F:F)

    F:F is empty ...

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    OK - I think I get it. Is this what you are looking for?

    =SUMIF(Sheet1!C:C,A3,Sheet1!M:M)+SUMPRODUCT($F$2:$L$9*($F$1:$L$1=A3))
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi,

    What I'd like is a total in sheet 2 company 1 column B (running totals 2024) to add all of sheet 1 column M (Total cost £) and all of sheet 2 column F (Company 1). The formula added all of column M but not column F.
    Column F has 3 values in it.

    Thanks

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    See post #21.

  24. #24
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi sorry it's column F on sheet 2 I'd like to add not sheet 1, as you are right that is empty.

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    See post #21 ...

  26. #26
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hi,
    I tried it back in my original workbook but I want the sheet 2 column F value to run for the whole if the column (as I will be adding more values) it gives me a NA error.
    Thanks for all your help.

  27. #27
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Found a solution.

    =SUMIF(sheet 1'!C:C,"company 1",'sheet 1'!M:M)+SUM(F:F). This gives me the correct value.

  28. #28
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,856

    Re: Sum calculation

    You should STOP using full column references, as you don't need them and they can start to slow your workbook down. Just make ranges longer than you need.

    What is the problem with this?

    =SUMIF(Sheet1!C:C,A3,Sheet1!M:M)+SUMPRODUCT($F$2:$L$10000*($F$1:$L$1=A3))

    This:

    =SUMIF(sheet 1'!C:C,"company 1",'sheet 1'!M:M)+SUM(F:F)

    is a massive step backwards, as you will have to adjust it manually for each company. Mine above can be drag copied down without having to adjust anything.

    Glad to have helped.

    If you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.
    Attached Files Attached Files
    Last edited by AliGW; 07-12-2024 at 03:40 AM. Reason: Workbook added.

  29. #29
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,422

    Re: Sum calculation

    Thanks for the rep, Kirsten. I see the conversation continued apace this morning.

    Pete

  30. #30
    Registered User
    Join Date
    10-17-2023
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Microsoft Office LTSC professional Plus 2021
    Posts
    40

    Re: Sum calculation

    Hmm yes it did.

+ 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] Age calculation to today formula calculation error - in a single cell [Excel 2016]
    By NigeJG in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-24-2023, 04:09 AM
  2. CUMIPMT calculation doesn't seem to match interest calculation from amortization table
    By cdub39 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 11-28-2021, 08:11 PM
  3. [SOLVED] VBA to open a workbook with manual calculation and close with automatic calculation
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2019, 12:28 PM
  4. [SOLVED] Calculation of dates and leaving blank cell when calculation sees non-date values
    By Hedy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2018, 07:52 AM
  5. Replies: 0
    Last Post: 05-17-2014, 10:18 PM
  6. Replies: 1
    Last Post: 01-15-2013, 08:51 AM
  7. [SOLVED] Conditional statement calculation based on result of previous calculation.(Need some help)
    By takeprofit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-01-2012, 01:45 AM

Tags for this Thread

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