+ Reply to Thread
Results 1 to 8 of 8

Error using SUMPRODUCT to count variable between a date range

  1. #1
    Registered User
    Join Date
    11-30-2009
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2003 (not by choice)
    Posts
    6

    Error using SUMPRODUCT to count variable between a date range

    I am using Excel 2003. Since I don't have COUNTIFS, I am using SUMPRODUCT to count the number of times that Column L (Change Type)="Mech" occurs during the month of March, 2011 (Column B is the date). See attached workbook; my formula is giving me an incorrect answer.

    Here is the code I came up with:
    Please Login or Register  to view this content.
    In plain language, I am looking for the number of times that Column B is between 03/01/2011 and 03/31/2011 AND the value of Column L is equal to "Mech". My problem is that my answer should be 14, but my formula is giving me 13. Please see attached file.

    What am I doing wrong? Is there a simpler or more elegant way of doing this?

    I appreciate any assistance, Thanks.
    Attached Files Attached Files
    Last edited by Chevy Nick; 04-22-2011 at 10:07 AM.

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

    Re: Error using SUMPRODUCT to count variable between a date range

    You have a trailing space in L231 - use a TRIM as necessary.

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Error using SUMPRODUCT to count variable between a date range

    Try this
    Please Login or Register  to view this content.
    You have mixed US/UK date formats
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

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

    Re: Error using SUMPRODUCT to count variable between a date range

    Marcol, the date values in the original are fine given OP locale (03/01 & 03/31 being 1st March & 31st March respectively)

    The issue as outlined relates to a trailing space causing the ="Mech" test to fail for one record.

    The corrected version would look like:

    Please Login or Register  to view this content.
    or, if we assume monthly analysis at all times:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Error using SUMPRODUCT to count variable between a date range

    @ DonkeyOteThat just dawned on me, a bit to late however!
    Last edited by Marcol; 04-22-2011 at 05:13 AM. Reason: Removed signature to reduce clutter

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Error using SUMPRODUCT to count variable between a date range

    As an apology for my earlier blunder, I have "developed" Dons' second formula (Post #4).

    This should work regardless of the machine date settings.

    Select from the drop-downs A7:C7

    All credits to DonkeyOte.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-30-2009
    Location
    El Paso, TX
    MS-Off Ver
    Excel 2003 (not by choice)
    Posts
    6

    Re: Error using SUMPRODUCT to count variable between a date range

    Thanks for your help. DonkeyOte; how did you find the trailing space in L231?

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Error using SUMPRODUCT to count variable between a date range

    i dont know about donkyote but when you open your sample you can see l231 is aligned diferently
    i'd wonder why and check it,
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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