+ Reply to Thread
Results 1 to 5 of 5

Thread: SUMIF - add values from one column based on values in two other columns

  1. #1
    Registered User
    Join Date
    01-28-2006
    Posts
    10

    SUMIF - add values from one column based on values in two other columns

    I see similar questions and solutions, but I keep getting a error using the following that I used from another example in this forum.

    SUMPRODUCT(--(A2:A15=A21);--(B2:B15=B21)@;N2:N15)

    I am referencing other sheets in the workbook and I can't get past the inserted @ above.

    My columns are :

    Hours JOB Date
    8 ci 2/6
    6 ex 2/6
    8 ci 2/7
    6 ci 2/6



    I want to add the hours of job ci on Feb 6th. should be 14.

    Thanks, mike

  2. #2
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile

    Good morning goodmike

    If your Hours are in A, the Job in B and the Date in C and you want to add column A, based on the values in B21 and C21 then this formula will help :
    =SUMPRODUCT(--(B2:B15=B21),--(C2:C15=C21),(A2:A15))

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    06-22-2005
    Posts
    33
    I was able to use this formula today to help me with a spreadsheet.

    I have a question though. What does the double dash '--' signify in the formula? The formula doesn't work without it so it has to do something, correct?

  4. #4
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057
    B2:B15=B21 returns an array of TRUE/FALSE values. -- converts these to 1/0 values which SUMPRODUCT can then deal with. There are other ways to do that conversion, e.g. you can use

    =SUMPRODUCT((B2:B15=B21)+0,(C2:C15=C21)+0,A2:A15)

    ...or a slightly different syntax.....

    =SUMPRODUCT((B2:B15=B21)*(C2:C15=C21),A2:A15)

    For more information on uses of SUMPRODUCT see here

  5. #5
    Registered User
    Join Date
    06-22-2005
    Posts
    33
    thanks for the answer. I've used the "*" before, but never seen the "--".

    That link is also very helpful in understanding sumproduct.

    thanks!

    -joel

+ 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.2.0