+ Reply to Thread
Results 1 to 10 of 10

Thread: Summing Column within date range

  1. #1
    Registered User
    Join Date
    09-08-2008
    Location
    canada
    Posts
    6

    Summing Column within date range

    Hello all,

    I would really appreciate some help. I'm working on a worksheet that has dates in one column (column A), and numbers in another column (column B). What I'm looking to do, is look through all of column A, find all entries between a certain date (ie Nov 1 07 - Nov 30 07), and sum all the values in column B that correspond those fields, as long as the value is greater than zero or not blank.

    So, for example,

    A B
    Nov 1 1
    Nov 6 -5
    Nov 3 6
    Dec 6 5
    Jan 1 2

    I would need the formula to return 7

    Any help would be really appreciated =)

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636
    =SUMPRODUCT((A1:A10>=X1)*(A1:A10<=X2)*(B1:B10>0),B1:B10)

    Where X1 and X2 contain the start and end dates, respectively.

    A1:B10 contain your data

    edit: Changed formula to include B1:B10>0
    Last edited by NBVC; 09-08-2008 at 10:25 AM. Reason: Changed formula
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,566
    Hi,

    How do you get 7? The values for November total '2'.

    Are the dates on column A proper Excel date numbers or just text characters which spell out 'Nov', 'Dec' etc...

    Rgds

  4. #4
    Registered User
    Join Date
    09-08-2008
    Location
    canada
    Posts
    6
    hey richard,
    i got 7 from summing Nov 1 & 3 (nov 6th is negative, which i need to exclude). The date column is in date format.

    NBVC, thanks for the reply, I will try this =)

  5. #5
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,566
    Quote Originally Posted by excalibur69 View Post
    hey richard,
    i got 7 from summing Nov 1 & 3 (nov 6th is negative, which i need to exclude). The date column is in date format.
    Ah, OK

    I was interpreting you quite literally (and logially) when you said
    greater than zero or not blank.
    I see you really meant:

    greater than zero AND not blank.

  6. #6
    Registered User
    Join Date
    09-08-2008
    Location
    canada
    Posts
    6
    hey guys, thanks again .. Stupid question, but how exactly to input the date in the formula? i put it in quotations as it appears on the sheet (ie "01-Nov-07"), but it wont seem to take it. Also, instead of going B1:B10, for instance, will the formula work if I just use B:B for the entire column as things will continuously be added?

    Thanks again

  7. #7
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636
    If you want to input the "hard coded date" in the formula... then

    =SUMPRODUCT((A1:A10>="01-Nov-07"+0)*(A1:A10<="01-Nov-07"+0)*(B1:B10>0),B1:B10)

    With Sumproduct you have to use defined ranges, not whole column ranges.. unless you have XL2007...

    To work around, you can define the range as, for example, B2:B65536
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  8. #8
    Registered User
    Join Date
    09-08-2008
    Location
    canada
    Posts
    6
    NBVC, you are a lifesaver. one more question if I could ask. The Sumproduct works great, but now I need to divide the figure from the sumproduct by the number of columns I got instances from, to give me an average. I would like to use the same conditions as you stated above for the count function..so for example. I would like to have =SUMPRODUCT((A1:A10>="01-Nov-07"+0)*(A1:A10<="01-Nov-07"+0)*(B1:B10>0),B1:B10)/COUNTIF((A1:A10>="01-Nov-07"+0)*(A1:A10<="01-Nov-07"+0)*(B1:B10>0),B1:B10)

    I know countif is not the correct formula to use here, but any help would be really appreciated

    thanks again
    Last edited by excalibur69; 09-08-2008 at 12:17 PM. Reason: typo

  9. #9
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636
    Try:

    =SUMPRODUCT((A1:A10>="01-Nov-07"+0)*(A1:A10<="01-Nov-07"+0)*(B1:B10>0),B1:B10)/SUMPRODUCT((A1:A10>="01-Nov-07"+0)*(A1:A10<="01-Nov-07"+0)*(B1:B10>0))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  10. #10
    Registered User
    Join Date
    09-08-2008
    Location
    canada
    Posts
    6
    works awesome! thanks again!

+ 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. Test whether date is within range
    By Jimmy1214 in forum Excel Programming
    Replies: 1
    Last Post: 07-15-2008, 03:30 PM
  2. Getting date range data from 1 or 2 sheets
    By Attila in forum Excel - New Users
    Replies: 0
    Last Post: 06-06-2008, 11:32 AM
  3. Date Range Parameter Query
    By msmouse523 in forum Excel Worksheet Functions
    Replies: 3
    Last Post: 08-02-2007, 03:33 PM
  4. Date Range Selections
    By Jennybob in forum Excel Programming
    Replies: 5
    Last Post: 02-08-2007, 01:24 PM
  5. Fill values down to the bottom cell of a column range
    By reclining in forum Excel Programming
    Replies: 2
    Last Post: 12-15-2006, 07:22 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.2.0