+ Reply to Thread
Results 1 to 5 of 5

Thread: Sumproduct across several columns

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    49

    Sumproduct across several columns

    I have the following code in a sheet, it looks at a range of cells and for those containing "READING" in Column BS it looks to Column CJ to see if its value is less than the value 1. The problem is that the word "READING" could be in one of 8 co


    =SUMPRODUCT(--($BS$6:$BS$45="READING"),--(CJ$6:CJ$45=""))
    The problem is that the word "READING" could be in one of 8 columns. (BS to BZ)

    I've tried using the following code but it returns #VALUE! Has anybody got any idea how I can make this work.

    =SUMPRODUCT(--($BS$6:$BZ$45="READING"),--(CJ$6:CJ$45=""))
    Last edited by BobTheRocker; 01-26-2011 at 11:09 AM. Reason: Solved

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Sumproduct across several columns

    Perhaps:

    =SUMPRODUCT(ISNUMBER(MATCH("READING",$BS$6:$BZ$45,0))*(CJ$6:CJ$45=""))
    The above assumes that should READING occur more than once per row you wish to count as 1 instance only - if not:

    =SUMPRODUCT(($BS$6:$BZ$45="READING")*(CJ$6:CJ$45=""))
    The 2nd is in essence an adaptation of your approach - note with Arrays of different dimensions (1x8 & 1x1) you must multiply the Arrays together as opposed to coercing each separately via double unary (#VALUE!)
    See the link in my sig. to Bob Phillips' white paper for more info. on SUMPRODUCT

  3. #3
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Sumproduct across several columns

    Thank you for your reply, I tried both but both returned zero when they should return 1. The first code you mentioned would be preferable as I would like to record several instances of reading as only 1 (though this is not essential).

    =SUMPRODUCT(ISNUMBER(MATCH("READING",$BS$6:$BZ$45,0))*(CJ$6:CJ$45=""))
    this should return 1 when it matches the word READING in a column BS to BZ and in the corresponding row for column CJ it sees a blank.

    I tested it again using just one column (BS) and this works for one column but the word could appear in 1 of 8 columns.

    =SUMPRODUCT(--($BS$6:$BS$45="READING"),--(CJ$6:CJ$45=""))
    Any ideas what I'm doing wrong?

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Sumproduct across several columns

    You're not doing anything wrong - the example I gave you won't work - simple as ! Ooops.

    =SUMPRODUCT(ISNUMBER(SEARCH("^READING^","^"&$BS$6:$BS$45&"^"&$BT$6:$BT$45&"^"&$BU$6:$BU$45&"^"&$BV$6:$BV$45&"^"&$BU$6:$BU$45&"^"&$BV$6:$BV$45&"^"&$BW$6:$BW$45&"^"&$BX$6:$BX$45&"^"&$BY$6:$BY$45&"^"&$BZ$6:$BZ$45&"^"))*(CJ$6:CJ$45=""))
    obviously if you could create a single concatenation string on each row (aping above) then that would simplify the SUMPRODUCT

  5. #5
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Sumproduct across several columns

    Thanks very much for your help and how strange because just tried those formula with another example in a smaller worksheet and they work, so I tried them again in my main project and indeed both examples below work based on you coding.

    =SUMPRODUCT((BS6:BZ45="READING")*(CJ117:CJ156<1))
    =SUMPRODUCT((BS8:BZ45="READING")*(CJ8:CJ45=""))
    I will try your third example as well and see what that throws up. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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