ASSUMING my previous interpretation is correct, then the logic is: The starting date for each "year" is the larger of the first day of the year in row 1, and the date in column B. to determine THAT, the start date would be: Start Date = MAX($B2,DATEVALUE("1/1/"&D$1))
The End date would be the smaller of the last day of the year in row 1, and the date in column C so: End Date = MIN($C2,DATEVALUE("1/1/"&D$1+1)) So, the difference between these two dates would be (End Date) - (Start Date): =MIN($C2,DATEVALUE("12/31/"&D$1))-MAX($B2,DATEVALUE("1/1/"&D$1)) This difference doesn't INCLUDE counting the last day, it's the number BETWEEN the dates, so you'd have to add (1) to get the total days: =MIN($C2,DATEVALUE("12/31/"&D$1))-MAX($B2,DATEVALUE("1/1/"&D$1))+1 Now, the problem is that if the End date is BEFORE the first of the year in Row 1, then the number of days would actually be NEGATIVE, so you'd want to check that to ensure it returns (0). For that you can use the MAX() function The final result would be: =MAX(MIN($C2,DATEVALUE("12/31/"&D$1))-MAX($B2,DATEVALUE("1/1/"&D$1))+1,0) putting this formula into Cell D2 and copying down and across results in the sample results you supplied. hope this helps. Paul ----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley ----------------------------------------- ________________________________ From: Paul Schreiner <schreiner_p...@att.net> To: excel-macros@googlegroups.com Sent: Tue, February 19, 2013 7:42:26 AM Subject: Re: $$Excel-Macros$$ Count No of Days between Start and End Date over a period of different years I'm really very sorry, but your explanation continues to make no sense. Basically, it's this: You want the number of days between two dates. For that, you need two dates. So, in your example, the solution in D2 of 365 days. What was used as the Start Date and what was used as the End Date? perhaps, what you are saying is: Given the Start and End Date(s) in Columns B and C, how many of the days within THAT range appeared in the year(s) shown in D1, E1 and F1? So basically, if the total number of days between B2 and C2 is 1044, then the total days within 2010 + the total within 2011 and the total within 2012 should equal 1044. Is that what you're trying to get to? Paul ----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley ----------------------------------------- ________________________________ From: prkhan56 <prkha...@gmail.com> To: excel-macros@googlegroups.com Sent: Tue, February 19, 2013 6:21:59 AM Subject: Re: $$Excel-Macros$$ Count No of Days between Start and End Date over a period of different years Thanks for the response. Both the solution does not give the result I wish to have... Let me try to explain it with the Data in S.No. 1 only I wish to have a formula in D2 which will calculate the elapsed days between the Start and End Date under that particular year. For example S.No. under 2010 it should show 365 days as the full year has passed and then under 2011 the balance days under that particular year and same for year 2012. In the sample file I have provided I have put the numbers which should appear under each year manually. Hope this is clear now On Tuesday, February 19, 2013 12:29:45 AM UTC+4, Paul Schreiner wrote: Your cell in yellow is not a formula. > >So you're saying you want to take the Month/day from B and C, the Year from >D/E/F >and calculate the number of days between the Start/End dates built from these >combinations? >Basically, you'd build the date for the ending date: >=DATEVALUE(MONTH($C2)&"/"&DAY( $C2)&"/"&D$1) >subtract the date obtained from the beginning date: >-DATEVALUE(MONTH($B2)&"/"&DAY( $B2)&"/"&D$1) > >and copy that down and across. > >If that's not what you're looking for, >then please provide more information. > > >Paul >------------------------------ ----------- >“Do all the good you can, >By all the means you can, >In all the ways you can, >In all the places you can, >At all the times you can, >To all the people you can, >As long as ever you can.” - John Wesley >------------------------------ ----------- > > > > > ________________________________ From: Rashid Khan <prkh...@gmail.com> >To: excel-...@googlegroups.com >Sent: Mon, February 18, 2013 3:11:46 PM >Subject: $$Excel-Macros$$ Count No of Days between Start and End Date over a >period of different years > > >Hello All, >I am attaching a sample file for my problem. > >I wish to have a formula entered in Cell D2 (highlighted in yellow - to be >dragged across and down) to calculate the number of days in Col D, E and F >over >different years from the Start and End Date. > >Thanks in advance >Rashid Khan-- >Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >https://www.facebook.com/ discussexcel > >FORUM RULES > >1) Use concise, accurate thread titles. Poor thread titles, like Please Help, >Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get >quick attention or may not be answered. >2) Don't post a question in the thread of another member. >3) Don't post questions regarding breaking or bypassing any security measure. >4) Acknowledge the responses you receive, good or bad. >5) Jobs posting is not allowed. >6) Sharing copyrighted material and their links is not allowed. > >NOTE : Don't ever post confidential data in a workbook. Forum owners and >members >are not responsible for any loss. >--- >You received this message because you are subscribed to the Google Groups "MS >EXCEL AND VBA MACROS" group. >To unsubscribe from this group and stop receiving emails from it, send an >email >to excel-macros...@ googlegroups.com. >To post to this group, send email to excel-...@googlegroups.com. >Visit this group at http://groups.google.com/ group/excel-macros?hl=en. >For more options, visit https://groups.google.com/ groups/opt_out. > > >-- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en. For more options, visit https://groups.google.com/groups/opt_out.