+ Reply to Thread
Results 1 to 16 of 16

Excel 2007 : SUMPRODUCT over several columns

  1. #1
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    SUMPRODUCT over several columns

    Greetings,

    How may I make the following formula look for the word "Online" in columns C, D, E, or F as well?
    =SUMPRODUCT(--(C:C="Online"),--(A:A=>DATE(2008,1,1)),--(A:A<=DATE(2008,12,31)),B:B)

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    Try:

    =SUMPRODUCT((C:F="Online")*(A:A>=DATE(2008,1,1))*(A:A<=DATE(2008,12,31))*B:B)

    although probably very slow.. You should use defined ranges instead of full ranges...
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: SUMPRODUCT over several columns

    I think, in your situation, you could use something like this:
    Please Login or Register  to view this content.
    Using fewer functions should reduce the calculation overhead and shorten the
    recalc time.

    Note: that formula only works if the same row will NOT contain "online" more than once.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    Ron, I don't have a stop watch or anything.. but that didn't really seem that noticeably quicker when I plugged it in my sample sheet...

    ... and as Ron mentioned, if ONLINE appears more than once, then it will sum column B that many more times at those rows of duplication....

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: SUMPRODUCT over several columns

    Quote Originally Posted by NBVC View Post
    Ron, I don't have a stop watch or anything.. but that didn't really seem that noticeably quicker when I plugged it in my sample sheet...
    I did say "should reduce..."

    Sometimes it's a combination of small, seemingly insignificant, efficiencies that cause a noticeable reduction in recalc time.

  6. #6
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    Re: SUMPRODUCT over several columns

    Thanks folks, but both formulas are resulting in a #VALUE! error

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    Probably you have a text title in column B... you can't have that with this formula...

    You need to eliminate the titles or used defined ranges that start at row 2.

  8. #8
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    Re: SUMPRODUCT over several columns

    Folks,
    Thanks again, I haven't gotten it to work right so far, but before we proceed I want to verify what you had said (about if the word "online" was in the row, more than once) in an example:

    A B C
    $50 Online Online
    $10 Online
    $20 Online

    I am hoping that the count would be 3 and the total would be $80, but from what people were saying about "online" appearing the row more than once it could be count 4 and total $130. Please confirm either way.

    Thanks a lot!
    Bryce

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    It is the latter... 4 and $130

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    One solution would be to add a helper column that identifies if there is at least one "Online" in the row and then use that column in your sumproduct...

    so if in column A you add formula:

    =ISNUMBER(MATCH("online",C1:F1,0)) and copy down...

    then =SUMPRODUCT((A:A=TRUE)*B:B)

    will find the TRUE's in column A and return 1 for each TRUE found and multiply that by corresponding cell in column B.. then sum them all up for a grand total.

  11. #11
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    Re: SUMPRODUCT over several columns

    I like the helper column idea a lot, but I can make it do more for me like, instead of resulting in TRUE, result in Online?

    If the answer is yes, can you give me a formula that can do that for several categories, like Direct Mail, etc???

    So the results would be:

    A B C D
    Online $50 Online Online
    Direct Mail $180 Direct Mail
    Visit $15 Visit
    Newsletter $20 Newsletter

    Thanks so so much!
    Bryce

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    Try:

    =INDEX(C1:F1,MATCH(TRUE,INDEX(C1:F1<>"",0),0))

    copied down.

  13. #13
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    Re: SUMPRODUCT over several columns

    This is great. One more addition (if possible)

    If column D = "Multiple" then display text from column E

    Thanks!

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    Is that to be incorporated in the previous formula so that it overrides the previous formula result?

  15. #15
    Registered User
    Join Date
    11-10-2009
    Location
    Watkins Glen, NY
    MS-Off Ver
    Excel 2007/2003
    Posts
    48

    Re: SUMPRODUCT over several columns

    Yes

    Because most of the columns are repeated,

    C D
    Newsletter Newsletter

    Some are empty in D

    Newsletter

    And some are

    Multiple Newsletter

    I want them to be newsletter too.

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUMPRODUCT over several columns

    I'm going to say:

    =IF(D1="Multiple",E1,INDEX(C1:F1,MATCH(TRUE,INDEX(C1:F1<>"",0),0)))

+ 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