Array Sum Room Nights

ricafonyat

New Member
Joined
May 1, 2017
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hello!!

I am looking for help to build an array formula that compute by month and year the number of room nights according the hotel reservations book


[TABLE="width: 390"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Hotel Reservations[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Check-in Date[/TD]
[TD]Check-out Date[/TD]
[TD]Room Nights[/TD]
[/TR]
[TR]
[TD]Apr.30.2017[/TD]
[TD]May.02.2017[/TD]
[TD] 2[/TD]
[/TR]
[TR]
[TD]May.01.2017[/TD]
[TD]May.02.2017[/TD]
[TD] 1[/TD]
[/TR]
[TR]
[TD]May.03.2017[/TD]
[TD]May.06.2017[/TD]
[TD] 3[/TD]
[/TR]
[TR]
[TD]May.10.2017[/TD]
[TD]May.11.2017[/TD]
[TD] 1[/TD]
[/TR]
[TR]
[TD]May.12.2017[/TD]
[TD]May.15.2017 [/TD]
[TD] 3[/TD]
[/TR]
[TR]
[TD]May.30.2017[/TD]
[TD]Jun.02.2017[/TD]
[TD] 3[/TD]
[/TR]
[TR]
[TD]Jun.03.2017[/TD]
[TD]Jun.05.2017[/TD]
[TD] 2[/TD]
[/TR]
[TR]
[TD]Jun.30.2017[/TD]
[TD]Jul.01.2017[/TD]
[TD] 1[/TD]
[/TR]
[TR]
[TD]Jul.02.2017[/TD]
[TD]Jul.05.2017 [/TD]
[TD] 3[/TD]
[/TR]
[TR]
[TD]Jul.06.2017[/TD]
[TD]Jul.10.2017[/TD]
[TD] 4[/TD]
[/TR]
[TR]
[TD]Jul.15.2017[/TD]
[TD]Jul.22.2017[/TD]
[TD] 7[/TD]
[/TR]
[TR]
[TD]Jul.25.2017[/TD]
[TD]Aug.01.2017[/TD]
[TD] 7[/TD]
[/TR]
[TR]
[TD="colspan: 2"]Total Room Nights[/TD]
[TD] 37
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 286"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Month[/TD]
[TD]Room Nights[/TD]
[/TR]
[TR]
[TD]Jan.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Feb.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Mar.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Apr.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]May.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Jun.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Jul.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Aug.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Sep.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Oct.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Nov.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Dec.17[/TD]
[TD] ?[/TD]
[/TR]
[TR]
[TD]Total Room Nights[/TD]
[TD] 37[/TD]
[/TR]
</tbody>[/TABLE]

Any help would be appreciated
Rica
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try

Dates, numbers not text, in columns A:B as dd/mm/yyyy
Months, numbers not text, in E2:E13
Some abbreviations of the months in Portuguese are different from English but very similar (fev instead of feb, abr instead of apr, etc...)


[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Check-in Date​
[/td][td]
Check-out Date​
[/td][td]
Room Nights​
[/td][td][/td][td]
Month​
[/td][td]
Room Nights​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
30/04/2017​
[/td][td]
02/05/2017​
[/td][td]
2​
[/td][td][/td][td]
jan/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
01/05/2017​
[/td][td]
02/05/2017​
[/td][td]
1​
[/td][td][/td][td]
fev/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
03/05/2017​
[/td][td]
06/05/2017​
[/td][td]
3​
[/td][td][/td][td]
mar/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
10/05/2017​
[/td][td]
11/05/2017​
[/td][td]
1​
[/td][td][/td][td]
abr/17​
[/td][td="bgcolor:#F2F2F2"]
1​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
12/05/2017​
[/td][td]
15/05/2017​
[/td][td]
3​
[/td][td][/td][td]
mai/17​
[/td][td="bgcolor:#F2F2F2"]
11​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td]
30/05/2017​
[/td][td]
02/06/2017​
[/td][td]
3​
[/td][td][/td][td]
jun/17​
[/td][td="bgcolor:#F2F2F2"]
4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td]
03/06/2017​
[/td][td]
05/06/2017​
[/td][td]
2​
[/td][td][/td][td]
jul/17​
[/td][td="bgcolor:#F2F2F2"]
21​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td]
30/06/2017​
[/td][td]
01/07/2017​
[/td][td]
1​
[/td][td][/td][td]
ago/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
10
[/td][td]
02/07/2017​
[/td][td]
05/07/2017​
[/td][td]
3​
[/td][td][/td][td]
set/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
11
[/td][td]
06/07/2017​
[/td][td]
10/07/2017​
[/td][td]
4​
[/td][td][/td][td]
out/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
12
[/td][td]
15/07/2017​
[/td][td]
22/07/2017​
[/td][td]
7​
[/td][td][/td][td]
nov/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
13
[/td][td]
25/07/2017​
[/td][td]
01/08/2017​
[/td][td]
7​
[/td][td][/td][td]
dez/17​
[/td][td="bgcolor:#F2F2F2"]
0​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
14
[/td][td]
Total Room Nights​
[/td][td][/td][td]
37​
[/td][td][/td][td]
Total Room Nights​
[/td][td]
37​
[/td][/tr]
[/table]


Array formula in F2 copied down (gray area)
=SUM(IF(1-((A$2:A$13>EOMONTH(E2,0))+(E2>B$2:B$13)),IF(B$2:B$13>EOMONTH(E2,0),1+EOMONTH(E2,0),B$2:B$13)-IF(A$2:A$13>E2,A$2:A$13,E2)))
Ctrl+Shift+Enter

M.
 
Upvote 0
Thanks Marcelo!
It works perfectly!
Are you from Brasil?
Best Regards
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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