+ Reply to Thread
Results 1 to 17 of 17

SUMPRODUCT() results in an error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    SUMPRODUCT() results in an error

    Hi, Sir,

    I am using SUMPRODUCT() to count how many cells with values. In column A, the values are:

    Date
    01/11/2012
    #N/A

    The function I used is:

    =SUMPRODUCT(--(LEN($A$1:$A$5)>0))

    Which resulted in an error. How can make this work?

    Thanks a lot.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: SUMPRODUCT() results in an error

    Try

    =COUNTIF(A1:A5,">0")
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: SUMPRODUCT() results in an error

    Formula: copy to clipboard
    =SUMPRODUCT(IF(NOT(ISERROR($A$1:$A$5)),--(LEN($A$1:$A$5)>0),0))
    entered with ctrl+Shift+enter

  4. #4
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    Quote Originally Posted by Sindhus View Post
    Formula: copy to clipboard
    =SUMPRODUCT(IF(NOT(ISERROR($A$1:$A$5)),--(LEN($A$1:$A$5)>0),0))
    entered with ctrl+Shift+enter
    Is there anyway that we don't use array? It would be excellent.

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: SUMPRODUCT() results in an error

    Plain and simple
    =COUNT(A1:A5)
    ( if by values you mean numbers)

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: SUMPRODUCT() results in an error

    What do you mean by values???

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: SUMPRODUCT() results in an error

    If no Array formula, then you can use simple formulas with a helper(hidden) column.

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: SUMPRODUCT() results in an error

    What result do you expect? COUNTA counts all values including numbers, text, errors, i.e.

    =COUNTA(A1:A5)

    or to exclude #N/A errors

    =COUNTA(A1:A5)-COUNTIF(A1:A5,"#N/A")

    .....or (as Pepe says) COUNT function will count numbers only (not text or errors)

    =COUNT(A1:A5)
    Last edited by daddylonglegs; 11-01-2012 at 06:23 AM.
    Audere est facere

  9. #9
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    Thanks for many helps.

    Sorry that if SUMPRODUCT() is really to be used (as a good knowledge), how can I add another condition in this function to allow for cases with #NA? I tried to use:

    =SUMPRODUCT(--(LEN($A$1:$A$5)>0),ISNUMBER($A$1:$A$5)) But not working

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: SUMPRODUCT() results in an error

    Please indicate the results you expect, what do you want to count exactly? Technically an error value like #N/A is still a value, so to count all values use COUNTA

  11. #11
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    Quote Originally Posted by daddylonglegs View Post
    Please indicate the results you expect, what do you want to count exactly? Technically an error value like #N/A is still a value, so to count all values use COUNTA
    For the formula: =SUMPRODUCT(--(LEN($A$1:$A$5)>0),ISNUMBER($A$1:$A$5))

    If there is an error #N/A in a cell, then the result is also #N/A. If there is an error #DIV/0!, then the result is also #DIV/0!

    I just want to learn how to use SUMPRODUCT() function to allow for those cells with errors (i.e. they are not included for count).

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: SUMPRODUCT() results in an error

    I'm still not clear what you want to count, that will make a difference to the formula you use. I understand you want to exclude errors.....but do you want to count numbers only.....or text and numbers......or something else?

    If the answer is numbers only then I would use COUNT but if you want to use SUMPRODUCT you can use this version

    =SUMPRODUCT(--ISNUMBER($A$1:$A$5))

    .....but that doesn't include any text values (or logical values) in the count - do you need to include those too?

  13. #13
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    Quote Originally Posted by daddylonglegs View Post
    I'm still not clear what you want to count, that will make a difference to the formula you use. I understand you want to exclude errors.....but do you want to count numbers only.....or text and numbers......or something else?

    If the answer is numbers only then I would use COUNT but if you want to use SUMPRODUCT you can use this version

    =SUMPRODUCT(--ISNUMBER($A$1:$A$5))

    .....but that doesn't include any text values (or logical values) in the count - do you need to include those too?
    Yes, I want to count for both numbers and text values.

  14. #14
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    How to improve this formula to allow for cells with invalid values
    Hi Sir,

    I learned from the forum that we can use the formula below to calculate the total number of non-empty cells in a column A. But this formula does not allow cells with invalid values. That is, as long as some cells have errors (e.g., #N/A, #DIV/0!), then this formula will stop working.

    =SUMPRODUCT(--(LEN($A$1:$A$5)>0))

    Can you advise how to improve for this formula to allow for those cells with invalid values? Great to learn this. Thanks.

  15. #15
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: SUMPRODUCT() results in an error

    =counta(a1:a5)

  16. #16
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: SUMPRODUCT() results in an error

    I assume COUNTA is no good, Pepe because it will also count error values......on that basis the shortest way I know is to use this formula

    =COUNT(1/(A1:A5<>""))

    confirmed with CTRL+SHIFT+ENTER

    .....but if you want a "normal" formula with SUMPRODUCT try

    =SUMPRODUCT(ISNUMBER(MATCH((A1:A5<>"")+0,{1},0))+0)

  17. #17
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    347

    Re: SUMPRODUCT() results in an error

    Quote Originally Posted by daddylonglegs View Post
    I assume COUNTA is no good, Pepe because it will also count error values......on that basis the shortest way I know is to use this formula

    =COUNT(1/(A1:A5<>""))

    confirmed with CTRL+SHIFT+ENTER

    .....but if you want a "normal" formula with SUMPRODUCT try

    =SUMPRODUCT(ISNUMBER(MATCH((A1:A5<>"")+0,{1},0))+0)
    Too good to be true. Well learned!

+ 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