+ Reply to Thread
Results 1 to 3 of 3

Sum(if) problem

  1. #1
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    185

    Sum(if) problem

    I am using the following formula with ctrl+shift+enter to calculate the total number of cells that match month and date in certain cell (L8) here. I keep getting a zero. I tried this same formula to compare just one cell (so instead of putting $D$2:$D$1376 I put in only D17 and I get a 1 which means my date formats are ok... I checked few other cells too) but when I use it with range it doesn't work.

    Any insights why its not working. Any other better way of doing this?

    =SUM(IF(AND(MONTH($D$2:$D$1376)=MONTH(L8),YEAR($D$2:$D$1376)=YEAR(L8)),1,0))

    Thank you in advance,
    Jay

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736
    Hello Jay,

    You can't use AND in array formulas like this because it returns a single result rather than an array. I'd suggest using SUMPRODUCT, thus avoiding CSE. Try

    =SUMPRODUCT(--(MONTH($D$2:$D$1376)=MONTH(L8)),--(YEAR($D$2:$D$1376)=YEAR(L8)))

    or even

    =SUMPRODUCT(--(TEXT($D$2:$D$1376,"mmmyy")=TEXT(L8,"mmmyy")))

  3. #3
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    185

    Thank you

    I learned something new today. I am going home
    Thank you very much.

    Jay

+ 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