Consecutive cell count (with a catch)

oneillc9

New Member
Joined
Oct 21, 2014
Messages
6
Hi - thank you for viewing and I hope you can help me out.

Quite simply, in column A I have a list of all the dates in 2015 beginning on Jan 1st. For this example, Column B contains a name. Vacation days are entered in column B (marked with a 'V'). In cell B2 I want to add a check for whether or not the person has taken off 10 consecutive weekdays (i.e. 2 weeks holidays) at any point throughout the year.

I'm tempted to write a macro to loop through the cells but desperately want to avoid that. Is this possible using some kind or array formula?

Many thanks in advance.

DateJohn
2 Weeks Consecutive Holidays?[Y/N]
Thu-01-JanV
Fri-02-JanV
Sat-03-Jan
Sun-04-Jan
Mon-05-JanV
Tue-06-JanV
Wed-07-JanV
Thu-08-JanV
Fri-09-JanV
Sat-10-Jan
Sun-11-Jan
Mon-12-JanV
Tue-13-JanV
Wed-14-JanV

<tbody>
</tbody>
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The result would be Y given that John has taken 10 consecutive business days off (i.e. 2 weeks at once).
 
Upvote 0
But what is the result for the sample you provided?

The result for the sample above would be Y. I.e. there are 10 consecutive vacation days marked into the sheet.

Another example below further illustrates this. John will be on vacation for two weeks at one time whereas Mary has taken the same number of days off but will not be on vacation for two weeks at any one time.

John
Mary
2 weeks consecutive?
YN
Thu-01-Jan
v
Fri-02-Jan
v
Sat-03-Jan
Sun-04-Jan
Mon-05-Jan

v
Tue-06-Jan
v
Wed-07-Janv
Thu-08-Janv
Fri-09-Janvv
Sat-10-Jan
Sun-11-Jan
Mon-12-Janv
Tue-13-Janv v
Wed-14-Janv v
Thu-15-Janv v
Fri-16-Janvv
Sat-17-Jan
Sun-18-Jan
Mon-19-Janv
Tue-20-Janv
Wed-21-Jan
Thu-22-Jan
Fri-23-Jan v

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Aladin,

I believe he is after contiguous business days.

I know a simple =COUNTIFS($B$2:$B$16, "V") gives you a Ten count, but I don't know how to check for continuity- maybe some variation of NETWORKDAYS()?

~assuming his "V" for Vacation is begins at B2.
 
Upvote 0
If it helps, the largest 'block' of cells that can contain the 10 contiguous business days is 14 (including two weekends). Is there a way to check whether a count of cell values (countif or count) across any 'block' of 14 vertical cells is >=10?
 
Upvote 0
How about this into B2:

Code:
=IF(MAX(FREQUENCY(IF((B$3:B$25="v")*(LEFT($A$3:$A$25,3)<>"Sat")*(LEFT($A$3:$A$25,3)<>"Sun"),ROW(B$3:B$25)),IF((B$3:B$25<>"v")*(LEFT($A$3:$A$25,3)<>"Sat")*(LEFT($A$3:$A$25,3)<>"Sun"),ROW(B$3:B$25))))>=10,"Y","N")

This assumes date goes into column A as a string and that list is from B3 to B25:

JohnMaryMark
2 weeks consecutive?YN
Thu-01-Jan v
Fri-02-Jan v
Sat-03-Jan
Sun-04-Jan
Mon-05-Jan v
Tue-06-Jan v
Wed-07-Janv
Thu-08-Janv
Fri-09-Janvv
Sat-10-Jan
Sun-11-Jan
Mon-12-Janv
Tue-13-Janvv
Wed-14-Janvv
Thu-15-Janvv
Fri-16-Janvv
Sat-17-Jan
Sun-18-Jan
Mon-19-Janv
Tue-20-Janv
Wed-21-Jan
Thu-22-Jan
Fri-23-Jan v

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Thanks iliauk that works perfectly. i don't really understand how the bins_data section works. If I had a second option 's' that I wanted to also take into account how should I reorganise the formula? For example if it could be 'v' or 's'. Thanks again!
 
Upvote 0
iliauk's solution is based on you having text values in column A (not real dates) - if you have actual dates in A2:A367 then you can use this formula in B1

=IF(MAX(FREQUENCY(IF(WEEKDAY($A2:$A367,2)<6,IF(B2:B367={"v","s"},$A2:$A367)),IF(WEEKDAY($A2:$A367,2)<6,IF((B2:B367="v")+(B2:B367="s")=0,$A2:$A367))))>=10,"Y","N")

confirmed with CTRL+SHIFT+ENTER and copied across

That will take account of both "v" and "s"
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,390
Members
448,957
Latest member
Hat4Life

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