Formula that will cascade the number of nights

chesterrae

Board Regular
Joined
Dec 23, 2015
Messages
51
I need to distribute the Number of nights (column C) to column E to column K (Sunday to Saturday). The starting point of cascading is based on its Check in Day (column B).



check in datecheck in dayNo. of nightsSunMonTueWedThuFriSat
1/22/2017Sunday41111
7/20/2017Thursday11
1/29/2017Sunday112222111
1/24/2017Tuesday1
2/7/2017Monday4

<tbody>
</tbody>


Any formula or other method that would make easier than manual intervention.


Thank you in advance!
Have a great day!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Why is 1/29/2017 2 2 2 2 1 1 1 ? Why can;t it be 2 2 2 2 2 1 blank ? Or another combination?
Why are they 2s?
Why do the 2s stop on Thursday?

You need to explain this since you haven't mentioned this in your description of the problem.
 
Last edited:
Upvote 0
Hi,

You'll need to have numbers instead of day names in the top row (or another row with numbers from 1 to 7 hidden above them...)

Then you can use an array formula based on the check in date, no of nights and the day numbers, assuming check-in is in column A, nights are Column C, and day numbers are in row 1, starting at D1, your formula looks like this:

=SUM(IF(WEEKDAY(ROW(INDIRECT($A2&":"&$A2+$C2-1)),1)=D$1,1,0))

After typing, enter the formula by hitting CTRL+SHIFT+ENTER ! this is very important, add this to the top right corner of the cascading table and then drag to right and to the bottom

checkin datedaynights1234567
27/09/2017Wed10001000
28/09/2017Thu30000111
29/09/2017Fri71111111
30/09/2017Sat112221112
01/10/2017Sun142222222
02/10/2017Mon50111110

<colgroup><col><col span="2"><col span="3"><col><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi Special-K99,

The check in day of 1/29/2017 is Sunday with 11 No. of Nights, that's why the cascading of 11 nights from Sunday to Saturday should start first at sunday. (looping from left to right)
 
Upvote 0
Hi istiasztalos,

The formula works perfectly!
You're a genius!!

Thank you so much!





Hi,

You'll need to have numbers instead of day names in the top row (or another row with numbers from 1 to 7 hidden above them...)

Then you can use an array formula based on the check in date, no of nights and the day numbers, assuming check-in is in column A, nights are Column C, and day numbers are in row 1, starting at D1, your formula looks like this:

=SUM(IF(WEEKDAY(ROW(INDIRECT($A2&":"&$A2+$C2-1)),1)=D$1,1,0))

After typing, enter the formula by hitting CTRL+SHIFT+ENTER ! this is very important, add this to the top right corner of the cascading table and then drag to right and to the bottom

checkin datedaynights1234567
27/09/2017Wed10001000
28/09/2017Thu30000111
29/09/2017Fri71111111
30/09/2017Sat112221112
01/10/2017Sun142222222
02/10/2017Mon50111110

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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