+ Reply to Thread
Results 1 to 6 of 6

Total manhours in date range

  1. #1
    Registered User
    Join Date
    08-23-2017
    Location
    Dubai
    MS-Off Ver
    2016
    Posts
    20

    Total manhours in date range

    Sir,

    Good morning


    I am doing a program to find total man hours in a date range. ( excel sheet attached )

    Eg: I need to get total man hours of date range from 23 July 2017 - 26 Aug 2017.

    I have two cells for Begining date ( cell No. H36 ) and end date (cell No. L36). and total man hours ( cell No. J38) . Once i am changing the date value its need to calculate total manhours according to date range of the year of 2017 & 2018.


    I try to do with index, but its not working,
    Attached Files Attached Files

  2. #2
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Total manhours in date range

    First unmerge all the cells in row 1 and put 2017 and 2018 in each respective cell.

    Then result area should also unmerge

    then try

    J38[FORMULA=SUM(IF(DAY(H36)<=A3:A33,OFFSET(A2,1,MATCH(TEXT(H36,"MMM-YYYY"),B2:Y2&"-"&B1:Y1,0),31,),""),IF(DAY(L36)>=A3:A33,OFFSET(A2,1,MATCH(TEXT(L36,"MMM-YYYY"),B2:Y2&"-"&B1:Y1,0),31,),""),IFERROR(OFFSET(A2,1,MATCH(TEXT(H36,"MMM-YYYY"),B2:Y2&"-"&B1:Y1,0)+1,31,MATCH(TEXT(L36,"MMM-YYYY"),B2:Y2&"-"&B1:Y1,0)-MATCH(TEXT(H36,"MMM-YYYY"),B2:Y2&"-"&B1:Y1,0)-1),0))[/FORMULA]

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Check the attached file.
    Attached Files Attached Files
    Last edited by shukla.ankur281190; 09-07-2017 at 05:18 AM.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Total manhours in date range

    Another proposition:
    Cells in row 2 shall contain dates 2017-01-01 2017-02-01 etc and only be formatted to display month names (custom formatting "mmm")
    Then formula in J38:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    would do the job

    PS. Note that I used day numbers starting from empty cell (treated as 0 in A2, not A3:A33 - it is because upper left corner A3+B2 would be already Jan 2nd etc. while A2+B2=Jan 1st
    PS2. I started with much more complicated and (as it shows - unnecessary complicated formula first creating 31 by 24 arrays using MMult -
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Kaper; 09-07-2017 at 05:14 AM. Reason: Added note.
    Best Regards,

    Kaper

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Total manhours in date range

    @ Kaper,

    I really like your approach. One thing I noticed. If there are data entry errors ... for example data entered in 6/31 your formula will interpret this (correctly) as 7/1. Hours would get double counted. End user would have no clue it happened. February could be worse.

    If I may be permitted a modification of your SUMPRODUCT formula ...
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This is working at my end and ignores data entry errors.

    PS I forgot to mention it must be array entered.
    Last edited by FlameRetired; 09-07-2017 at 09:25 PM.
    Dave

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Total manhours in date range

    Hi Dave,

    Good point, but it leads to quite an increase in formula length and complication.
    May be it would be wise to unblock only "real dates" and leave blocked (default state) 30 Feb, 31 Apr etc. Then protect the sheet (even with no password).

    See attached.

    PS. Thanks for reputation point.
    Attached Files Attached Files

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Total manhours in date range

    Kaper, yes, I found the change complicating as well. I debated whether to post it.

    Cool unblocking solution in the upload. Much preferable to the formula I posted.
    I wonder if there is a VBA unblocking routine that could account for leap years as well. Unfortunately I know ~0 about VBA.

    PS. Thanks for the rep.

+ 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. Date and data lookup to total within a date range
    By greg123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-02-2016, 03:09 AM
  2. Replies: 8
    Last Post: 12-20-2015, 11:46 PM
  3. Replies: 3
    Last Post: 10-15-2015, 01:06 PM
  4. [SOLVED] Total revenue by a date range?
    By cchrisj in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-16-2014, 01:14 PM
  5. How to total vaules over a date range...
    By Jonbones22 in forum Excel General
    Replies: 7
    Last Post: 03-29-2014, 06:48 PM
  6. Total values from date range table
    By MrFoxar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2009, 04:49 PM
  7. Replies: 2
    Last Post: 04-19-2007, 08:46 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