+ Reply to Thread
Results 1 to 16 of 16

Formula for adding numbers based on month

  1. #1
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Formula for adding numbers based on month

    Hello. I am looking for a formula for N3 that adds up numbers in column J based of the date (Month only) in column A. The number 4 currently shown in N4 I have manually added, but I am looking for a formula that will give the same result.


    For example:
    test.jpg

    I have also attached the test excel file.
    Attached Files Attached Files
    Last edited by wonderd; 03-04-2015 at 07:52 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Formula for adding numbers based on month

    N3:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    However, your dates do not appear to be true dates.


    Regards, TMS
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    Will them not being true dates affect the result?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    try this, copied down...
    =SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3)*$J$3:$J$26)

    Trevor beat me to it.
    They seem like dates to me, Trevor, tested with =ISNUMBER(). I just opened the attached csv
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    They both have same result. What would be the better one to use? Or is the not a difference?

    Also Will them not being true dates affect the result?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Formula for adding numbers based on month

    @wonderd:
    Will them not being true dates affect the result?
    I would expect so.

    @Ford:
    They seem like dates to me
    maybe it's just a case of Regional Settings. When I open the csv file, some dates are not recognised as dates, and those that are probably have the day and month the wrong way round. But, in your part of the world, you probably both see them the same way ... no problem.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    1. if you opened Trevor's file, then you dont have 2003, Please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version.

    2. If your CSV always comes in that format, there should not ne a problem.

    3. Both the formulas are pretty much identcical, Trev used , I used *

    @ Trevor, yes that could be it. Mercans use mm/dd/yy (Im a Brit from Luton, via South Africa and USA)

  8. #8
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    Thanks guys, however may I please as another question?

    What would the formula look like if I wanted to do the same thing based on month but instead of adding the numbers, Only adding how many times (a number) appears. I know you just said WTF did he just say?

    For example. With this formula the correct value for N3 would be 2, because it just added how many times a number appears for January, the actual number does not matter. So if January had 4 different number show up in column J, the formula would return a (4) no matter what the actual value of those numbers were

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    remove the "sum" range...
    =SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3))

    Note this (and the others) will count/sum ALL Jan's and Febs etc. So if you had 3 years of data, it would count/sum data from all 3 Jans.

    If this could be a problem, then you would need to include a year in M3 etc, and change the TEXT part of formula to this...
    --(TEXT($A$3:$A$26,"mmmm yyyyy")=M3)

    This could have the problem of converting M3 to a real date is you add 2015 to January - unless you change the format of the month cells to Text

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Formula for adding numbers based on month

    Try:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS

  11. #11
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    I have tried
    Please Login or Register  to view this content.
    But its not working. I have edited the code slightly to go to row 50 but counts cells that do not have data. Screenshot here http://screencast.com/t/qwcBJbq1Q

    I plan on presetting the row to 9999. Is there a way to make it not count cells with no date?

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    Try this modification...
    SUM=SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3)*($A$3:$A$26<>"")*$J$3:$J$26)
    COUNT=SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3)*($A$3:$A$26<>""))
    They both worked on your sample data....
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    3
    1/25/2015
    TRUE
    2
    January
    4
    2
    4
    2/25/2015
    FALSE
    20
    February
    22
    2
    5
    3/1/2015
    FALSE
    2
    March
    4
    2
    6
    4/15/2015
    FALSE
    2
    April
    4
    2
    7
    5/13/2015
    FALSE
    2
    May
    4
    2
    8
    6/10/2015
    FALSE
    2
    June
    4
    2
    9
    7/16/2015
    FALSE
    2
    July
    4
    2
    10
    8/5/2015
    FALSE
    2
    August
    4
    2
    11
    9/16/2015
    FALSE
    2
    September
    4
    2
    12
    10/1/2015
    FALSE
    2
    October
    4
    2
    13
    11/1/2015
    FALSE
    2
    November
    4
    2
    14
    12/1/2015
    FALSE
    2
    December
    4
    2
    15
    1/25/2015
    TRUE
    2
    16
    2/25/2015
    FALSE
    2


    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    3
    TRUE
    2
    January
    2
    1
    4
    2/25/2015
    FALSE
    20
    February
    22
    2
    5
    3/1/2015
    FALSE
    2
    March
    4
    2
    6
    4/15/2015
    FALSE
    2
    April
    4
    2
    7
    5/13/2015
    FALSE
    2
    May
    4
    2
    8
    6/10/2015
    FALSE
    2
    June
    4
    2
    9
    7/16/2015
    FALSE
    2
    July
    4
    2
    10
    8/5/2015
    FALSE
    2
    August
    4
    2
    11
    9/16/2015
    FALSE
    2
    September
    4
    2
    12
    10/1/2015
    FALSE
    2
    October
    4
    2
    13
    11/1/2015
    FALSE
    2
    November
    4
    2
    14
    12/1/2015
    FALSE
    2
    December
    4
    2
    15
    1/25/2015
    TRUE
    2


    N3=SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3)*($A$3:$A$26<>"")*$J$3:$J$26)
    O3=SUMPRODUCT(--(TEXT($A$3:$A$26,"mmmm")=M3)*($A$3:$A$26<>""))

  13. #13
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    The below codes are working for me. Thank you kindly.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  14. #14
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    GHreat

    Did you read my note in post #9 regarding the year?

  15. #15
    Forum Contributor
    Join Date
    05-07-2013
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    215

    Re: Formula for adding numbers based on month

    Yea I did thanks, Year will likely not be an issue here. I am going to have different sheets for different years.

  16. #16
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Formula for adding numbers based on month

    OK good

+ 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. Replies: 4
    Last Post: 02-11-2015, 11:01 AM
  2. Formula for average duration for each month based on the ending month
    By bobby769 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-21-2013, 11:18 AM
  3. Replies: 4
    Last Post: 03-02-2013, 02:51 PM
  4. automatically adding days based off month
    By Josh_123456 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-17-2008, 11:34 AM
  5. Replies: 3
    Last Post: 09-25-2007, 10:26 AM

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