+ Reply to Thread
Results 1 to 11 of 11

Formula to check date range and then do calculation

  1. #1
    Registered User
    Join Date
    02-09-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    50

    Formula to check date range and then do calculation

    Hey guys
    I am looking for a single formula I can run along a single row that looks at several columns of data, and then checks if the date range falls between the running row, take it's relevant number, and multiply it by a single rate.
    The attached probably explains it clearly - I think the solution would be some sort of Sumproduct, but my attempts have failed!Example - Date Range with Calculation.xlsx

  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,422

    Re: Formula to check date range and then do calculation

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



    Regards, TMS
    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 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,422

    Re: Formula to check date range and then do calculation

    Or:

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



    Regards, TMS

  4. #4
    Registered User
    Join Date
    02-09-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Formula to check date range and then do calculation

    Oh awesome, thanks - is there anyway you can do it so that it uses the dates in row 2 to work out if it's between the period.

    So take H3, it would look at if the date is bigger that G2, or =< than H2, rather than match via date function?

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to check date range and then do calculation

    hi ps65,

    See if using a helper column or two works for you. If not then keep asking and we can find a harder method.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  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,422

    Re: Formula to check date range and then do calculation

    Or, probably worst option, an Array Formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    committed with Ctrl-Shift-Enter

    Regards, TMS

  7. #7
    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,422

    Re: Formula to check date range and then do calculation

    I'm not entirely sure what you're asking, or why.

    All the formulae that I have provided check from the first of the month to the month end date specified in row 2.

    Have you tried them in your workbook?

    Regards, TMS

  8. #8
    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,422

    Re: Formula to check date range and then do calculation

    If you do want to use just the dates in row 2, rather than the way I have done it, you will either need to include a dummy period end date at the beginning or have an inconsistent formula in the first cell.

    I wouldn't be happy with either option but it shouldn't be difficult for you to do if that's what you wish. I repeat, for you to do.

    Regards, TMS

  9. #9
    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,422

    Re: Formula to check date range and then do calculation

    OK, summary:

    F1 =SUMIFS($C$9:$C$12,$B$9:$B$12,">="&DATE(YEAR(F$2),MONTH(F$2),1),$B$9:$B$12,"<="&F$2)*$B$4
    F2 =SUMPRODUCT(($C$9:$C$12)*($B$9:$B$12>=DATE(YEAR(F$2),MONTH(F$2),1))*($B$9:$B$12<=F$2))*$B$4
    F3 =SUM(IF($B$9:$B$12>=DATE(YEAR(F$2),MONTH(F$2),1),IF($B$9:$B$12<=F$2,$C$9:$C$12)))*$B$4 with CSE
    F4* =SUMIFS($C$9:$C$12,$B$9:$B$12,">"&E$2,$B$9:$B$12,"<="&F$2)*$B$4
    * Enter 31/12/2009 in cell E2 and Custom format as "End of Period"

  10. #10
    Registered User
    Join Date
    02-09-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Formula to check date range and then do calculation

    Quote Originally Posted by TMS View Post
    OK, summary:

    F1 =SUMIFS($C$9:$C$12,$B$9:$B$12,">="&DATE(YEAR(F$2),MONTH(F$2),1),$B$9:$B$12,"<="&F$2)*$B$4
    F2 =SUMPRODUCT(($C$9:$C$12)*($B$9:$B$12>=DATE(YEAR(F$2),MONTH(F$2),1))*($B$9:$B$12<=F$2))*$B$4
    F3 =SUM(IF($B$9:$B$12>=DATE(YEAR(F$2),MONTH(F$2),1),IF($B$9:$B$12<=F$2,$C$9:$C$12)))*$B$4 with CSE
    F4* =SUMIFS($C$9:$C$12,$B$9:$B$12,">"&E$2,$B$9:$B$12,"<="&F$2)*$B$4
    * Enter 31/12/2009 in cell E2 and Custom format as "End of Period"
    Thanks, F4 was the solution I was looking for!

  11. #11
    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,422

    Re: Formula to check date range and then do calculation

    You're welcome.

    Not sure why you think that's a better option than just working with the date in the header, therefore introducing a second column dependency but, whatever, your choice.

    Regards, TMS

+ 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: 7
    Last Post: 07-14-2017, 12:04 PM
  2. excel formula help to get date from range as per check criteria
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2013, 06:03 AM
  3. conditional formatting formula to check frequency of occurence in date range?
    By seanblanton in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-27-2013, 05:50 PM
  4. How to check which weekday the date is and how to use it with calculation
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2011, 10:40 PM
  5. Formula to Check Column A for date range and count Column B
    By realniceguy5000 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-28-2009, 12:58 PM

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