+ Reply to Thread
Results 1 to 9 of 9

Add up multiple columns if month+year equals

  1. #1
    Registered User
    Join Date
    12-30-2009
    Location
    Wakefield, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Add up multiple columns if month+year equals

    Hi,
    I've spent quite a bit of time trying to figure out a way of doing this.
    I'll give an example of my worksheet:-

    Cost 1, Cost 2 , Date D/M/Y,
    £10.00, £20.00, 15/12/2009,
    £20.00, £10.00, 18/12/2009,
    £10.00, £10.00, 24/12/2009,
    £10.00, £10.00, 28/12/2009,
    £10.00, £20.00, 05/01/2010,

    The formula I currently have is
    =SUMIF(C:C,"<="&DATE(2009,12,31),A:A)-SUMIF(C:C,"<"&DATE(2009,12,1),A:A)
    But this will only add up column A and i want it to add column B as well for 1 month.

    From what I've read it sound like i need to use SUMPRODUCT but i can't seem to get it with that either.

    Sorry to trouble you and thanks in advance.

    Martin

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Add up multiple columns if month+year equals

    Hi,

    Assuming your data starts at A1, and that the dates are correctly formatted,

    =SUMPRODUCT((A2:B6)*(MONTH(C2:C6)=12)*(YEAR(C2:C6)=2009))

    will give the result I believe you require.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    12-30-2009
    Location
    Wakefield, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Add up multiple columns if month+year equals

    Excellent! Thank You very much for the fast reply.
    That should do the job except the data I want to to add up is in the entire B column and entire G column on my spreadsheet and its not very easy for me to move them around.

    Could i use something like this:-

    =SUMPRODUCT((B:B)*(G:G)*(MONTH(C:C)=12)*(YEAR(C:C)=2009))

    or have I just messed that up?
    I am using 2007 if that makes it any easier.

    Thanks
    Martin

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Add up multiple columns if month+year equals

    You can use whole columns, but it will slow your sheet down significantly. You might want to do a quick search for dynamic ranges.

  5. #5
    Registered User
    Join Date
    12-30-2009
    Location
    Wakefield, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Add up multiple columns if month+year equals

    Thank you very much for the info.
    For some reason i can't get =SUMPRODUCT((B:B)*(G:G)*(MONTH(C:C)=12)*(YEAR(C:C)=2009)) to work even if i set it like (b1:b100)*g1:g1000) it gets a value error. It works fine if its just for one row like B:B.
    I will have a read into dynamic ranges like you suggested.
    Thanks

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Add up multiple columns if month+year equals

    You will get the #VALUE! error if any cell contains non-numerics (eg: headers in row 1) given the explicit coercion being undertaken by means of multiplication (and Month / Year functions)

  7. #7
    Registered User
    Join Date
    12-30-2009
    Location
    Wakefield, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Add up multiple columns if month+year equals

    AHHHH!! of course! how thick of me, thanks a lot.

  8. #8
    Registered User
    Join Date
    12-30-2009
    Location
    Wakefield, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Add up multiple columns if month+year equals

    Just tried that now and your right it has got rid of the #Value but now it just shows £0.00
    The exact code I'm using is this =SUMPRODUCT(B2:B1000)*(M2:M1000)*(MONTH(G2:G1000)=12)*(YEAR(G2:G1000)=2009)
    Am I still being a bit stupid or does that look OK?

  9. #9
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Add up multiple columns if month+year equals

    =SUMPRODUCT((B2:B1000)*(M2:M1000)*(MONTH(G2:G1000)=12)*(YEAR(G2:G1000)=2009))

    might work out a little better

+ 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