+ Reply to Thread
Results 1 to 4 of 4

Problem with If and sumproduct formulas

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Problem with If and sumproduct formulas

    Hi,

    I have a sheet that contains rows containing letter codes for example "CU". This is generated by an IF formula i.e. If true = "CU". However I need to be able to calculate the number of instances of "CU" but sumproduct will not work as it sees the cell as containing a formula not the result i.e. "CU".

    Sumproduct code:

    Please Login or Register  to view this content.
    If code:

    Please Login or Register  to view this content.
    Thanks in advance
    Last edited by jpruffle; 03-30-2009 at 06:07 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,040

    Re: Problem with If and sumproduct formulas

    =countif(f5:f10;"cu")
    Never use Merged Cells in Excel

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

    Re: Problem with If and sumproduct formulas

    zbor has given you the correct formula -- ie use COUNTIF not SUMPRODUCT
    (note you will need to replace the ; with , as per your regional settings)

    However, to clarify your point:

    sumproduct will not work as it sees the cell as containing a formula not the result i.e. "CU"

    =SUMPRODUCT(D58:D61="CU")
    This is not so... the above will simply return a bunch of Boolean values (True/False), these are not numerical values thus can not be summed without coercion... you must therefore coerce the Booleans to integer, eg:

    =SUMPRODUCT(--(D58:D61="CU"))

    would work as here you're coercing each Boolean value (True/False) to integer equivalent (1 / 0 respectively) using the double unary operator (--)... the same could be achieved using 0+ or even 1*

    To reiterate however as zbor as clearly shown a non-array COUNTIF approah will suffice...

  4. #4
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Problem with If and sumproduct formulas

    Brilliant thank you

+ 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