+ Reply to Thread
Results 1 to 7 of 7

Sorting data by date within a date range

  1. #1
    Registered User
    Join Date
    07-24-2009
    Location
    CT
    MS-Off Ver
    Excel 2003
    Posts
    12

    Sorting data by date within a date range

    Hello, I have a question about sorting information using dates but using a range. I need this to sort when I enter a date range into the spreadsheet (the blue blocks on the attached spreadsheet). The factors in colum G need to be sorted by month and input into the yellow highlighted area in column B. There may be an easier way of pulling the data from the "Data" sheet but this was the best I could figure out. Overall, January (or any of the months)needs to have the January (or appropriate) factor that fits within the date range that was input but sorted properly based on the months listed in Column A.

    At this point I'm just beating my head against a wall and any help would be appreciated.

    Thanks,
    Nick

    edit: Solved, thanks!
    Attached Files Attached Files
    Last edited by 72mako; 12-31-2009 at 03:16 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sorting data by date within a date range

    If you only want to use the DATA sheet to get the results and avoid columns D to G, then try:

    =SUMPRODUCT(--(Data!$A$1:$A$24>=Sheet1!$A$2),--(Data!$A$1:$A$24<=Sheet1!$C$2),--(TEXT(Data!$A$1:$A$24,"mmmm")=Sheet1!A4),Data!$B$1:$B$24)

    else try:

    =SUMPRODUCT(--(TEXT($F$4:$F$15,"mmmm")=A4),$G$4:$G$15)

    copied down
    Where there is a will there are many ways.

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

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

  3. #3
    Registered User
    Join Date
    07-24-2009
    Location
    CT
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Sorting data by date within a date range

    NBVC, that worked perfect, thank you! I haven't used that function much so didn't even think of it. What are the "--" in the formula doing though?

    Thanks again,
    Nick

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sorting data by date within a date range

    They are used to coerce TRUE/FALSE results to 1's and 0's, respectively, so that the Sumproduct can continue doing the math.

  5. #5
    Registered User
    Join Date
    07-24-2009
    Location
    CT
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Sorting data by date within a date range

    so in the case of those formulas they are pulling "1" out of the true statements so the factors that I'm trying to input are showing (factor*1)? If one of my dates had a space after it in the cell that would come up as false and populate a "0" thereby showing me (factor*0)?

    Thanks,
    Nick

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sorting data by date within a date range

    As long as any one of the cells in your ranges meets the criteria set in the individual condions within the Sumproduct statement, then TRUE would be returned and the -- turn it into a 1...

    So if all 3 conditions in the Sumproduct return TRUE (or 1) at the same point, then the 3 together would be multiplied (as Sumproduct function is designed to do) and return a grand result of 1.. then the 1 is multiplied by the corresponding cell in the last range, Data!$B$1:$B$24, to return that number.

    Check this article out for a great Sumproduct() explanation with examples:

    http://www.xldynamic.com/source/xld.SUMPRODUCT.html

  7. #7
    Registered User
    Join Date
    07-24-2009
    Location
    CT
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Sorting data by date within a date range

    Excellent, thank you again!

    Nick

+ 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