+ Reply to Thread
Results 1 to 9 of 9

SUMPRODUCT Syntax (count cells that contain...)

  1. #1
    Forum Contributor
    Join Date
    01-09-2009
    Location
    NJ/NY
    MS-Off Ver
    Excel 2007 & 2016
    Posts
    124

    SUMPRODUCT Syntax (count cells that contain...)

    I am trying to use SUMPRODUCT to obtain the number of times the letter “M” or “U” occur in a column of data. The cells with these letters will also have numbers, i.e., M-1234; however, the values in these cells will always start with these letters (if present). I’m having difficulty with the syntax. I’ve tried SUMPRODUCT('Sheet1'!I6:I1200="M*")*('Sheet1'!I6:I1200="U*"), but this returns a value of zero; I know that here are currently 21 occurrences of either “M” or “U”. Can anyone tell me what’s wrong here?

    Thank you.
    Last edited by OverKnight; 12-27-2013 at 05:30 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,427

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Try it like this:

    SUMPRODUCT((LEFT('Sheet1'!I6:I1200)="M")+(LEFT('Sheet1'!I6:I1200)="U"))

    Note that + is equivalent to OR for arrays.

    Hope this helps.

    Pete

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Here's another one...

    =SUM(COUNTIF(Sheet1!I6:I1200,{"M*","U*"}))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Contributor
    Join Date
    01-09-2009
    Location
    NJ/NY
    MS-Off Ver
    Excel 2007 & 2016
    Posts
    124

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Thanks very much, Pete, and thank you for explaining the that + is equivalent to OR in array functions. Could I ask you to explain LEFT?

  5. #5
    Forum Contributor
    Join Date
    01-09-2009
    Location
    NJ/NY
    MS-Off Ver
    Excel 2007 & 2016
    Posts
    124

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Thank you, Tony. This worked perfectly also; there's more than one way to skin a cat!

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,427

    Re: SUMPRODUCT Syntax (count cells that contain...)

    LEFT takes characters from the left hand part of a cell. The full version is LEFT(A1,x), where x is the number of characters you want to take, but if it is missing it defaults to 1, so the function that I gave you just takes the first character within the cells of the range and then counts it if it is either "M" or "U".

    Hope this helps.

    Pete

  7. #7
    Forum Contributor
    Join Date
    01-09-2009
    Location
    NJ/NY
    MS-Off Ver
    Excel 2007 & 2016
    Posts
    124

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Thanks again, Pete. Have a great New Year!
    Last edited by OverKnight; 12-27-2013 at 05:38 PM.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,427

    Re: SUMPRODUCT Syntax (count cells that contain...)

    Same to you - thanks for the rep.

    Pete

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUMPRODUCT Syntax (count cells that contain...)

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. sumproduct syntax
    By amartino44 in forum Excel General
    Replies: 5
    Last Post: 12-26-2012, 08:58 PM
  2. Sumproduct subtotal filter count only bold cells
    By RxMiller in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-19-2011, 05:28 PM
  3. Syntax of sumproduct
    By SANDYFCOR in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2011, 04:12 AM
  4. sumproduct formula to count keyword in cells for a given month
    By philllipoosis in forum Excel General
    Replies: 1
    Last Post: 01-13-2011, 02:28 PM
  5. Sumproduct-how do i do that and keep the right syntax?
    By pelachrum in forum Excel General
    Replies: 3
    Last Post: 02-19-2007, 03:24 PM

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