Formula to count days in array based on criteria within a specific month

Dman333

Board Regular
Joined
Sep 30, 2016
Messages
68
Office Version
  1. 365
Platform
  1. Windows
Does anyone know if there is a method or function in excel that will total all the days in April and May separately? I have a large data set and calculate occupancy within a specific date range based on multiple criteria (using sumifs). Now I want to calculate the occupancy by month within that date range which could be 1 month or 1 year. A small example of a data set is below:

[TABLE="width: 225"]
<tbody>[TR]
[TD]Arrive[/TD]
[TD]Depart[/TD]
[TD]Total_Days[/TD]
[/TR]
[TR]
[TD="align: right"]4/2/2016[/TD]
[TD="align: right"]4/24/2016[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD="align: right"]4/4/2016[/TD]
[TD="align: right"]4/27/2016[/TD]
[TD]22[/TD]
[/TR]
[TR]
[TD="align: right"]4/6/2016[/TD]
[TD="align: right"]4/30/2016[/TD]
[TD]23[/TD]
[/TR]
[TR]
[TD="align: right"]4/8/2016[/TD]
[TD="align: right"]5/3/2016[/TD]
[TD]24[/TD]
[/TR]
[TR]
[TD="align: right"]4/10/2016[/TD]
[TD="align: right"]5/5/2016[/TD]
[TD]24[/TD]
[/TR]
[TR]
[TD="align: right"]3/27/2016[/TD]
[TD="align: right"]4/1/2016[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]3/29/2016[/TD]
[TD="align: right"]4/3/2016[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]3/31/2016[/TD]
[TD="align: right"]4/6/2016[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD="align: right"]4/2/2016[/TD]
[TD="align: right"]4/10/2016[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Excel 2010
BCDEFGHI
1
2ArriveDepartTotal_Days01-03-1601-04-1601-05-1601-06-16
32-Apr-1624-Apr-16230230
44-Apr-1627-Apr-16240240
56-Apr-1630-Apr-16250250
68-Apr-163-May-16260233
710-Apr-165-May-16260215
827-Mar-161-Apr-166510
929-Mar-163-Apr-166330
1031-Mar-166-Apr-167160
112-Apr-1610-Apr-169090
1215291358
1d
Cell Formulas
RangeFormula
E3=C3-B3+1
F3=MAX(0,MIN(G$2,$C3+1)-MAX(F$2,$B3))
G3=MAX(0,MIN(H$2,$C3+1)-MAX(G$2,$B3))
H3=MAX(0,MIN(I$2,$C3+1)-MAX(H$2,$B3))


N.B.
copy the formula down
sum the columns
This suggestion includes both the Start Date and the End Date
 
Last edited:
Upvote 0
Thanks - That works well though I was hoping to have a single cell for the formula and not have to add a bunch of columns to the worksheet because I'm just looking for the summary data. I don't think excel has a single function that will do this.
Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top