List all holidays in a column to a single cell

mukulesh

New Member
Joined
Feb 19, 2018
Messages
11
I have a sheet where I have the calendar for the entire year. For a working day, the value on the adjacent cell is 0 (zero). Anything other than zero against a date will represent a holiday.

A sample week in my calendar is something like this:

DateHoliday Remarks
22-Jan-20180
23-Jan-20180
24-Jan-20180
25-Jan-20180
26-Jan-2018Republic Day
27-Jan-20180
28-Jan-2018Sunday

<tbody>
</tbody>


Now, in another sheet, I want to list all holidays (only day of the date) between two dates. Input will be as follow:

Start Date:01-Jan-2018
End Date:31-Mar-2018

<tbody>
</tbody>

Finally I want the output as follows:

MonthsHolidays
Jan7, 14, 21,26,28
Feb4,11,18,25
Mar4,11,18,25

<tbody>
</tbody>

*I would like to avoid using VBA.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Maybe the suggestion below (with only formulas) can help you.

Lets go:

1) Create two blank sheets: Main and Sheet1. Put your Holidays Data in the rage A2:B366 (for 2018) of the sheet Sheet1 and in A1 , A2, A4 and B4 of the sheet Main put the texts Start, End, Months and Holidays.

ABCD
1DateHoliSheet
2seg-01/01/2018New YearSheet1
3ter-02/01/20180
4qua-03/01/20180
5qui-04/01/20180
6sex-05/01/20180
7sáb-06/01/20180
8dom-07/01/2018Sunday
9seg-08/01/20180
10ter-09/01/20180
11qua-10/01/20180
12qui-11/01/20180
13sex-12/01/20180
14sáb-13/01/20180
15dom-14/01/2018Sunday
16seg-15/01/20180
***************************************

<tbody>
</tbody>


ABCD
1Start01/jan/18Sheet
2End31/dez/18Main
3
4MonthsHolidays
5jan1, 7, 14, 21, 28
6fev4, 11, 13, 18, 25
7mar4, 11, 18, 25, 30
8abr1, 8, 15, 21, 22, 29
9mai1, 6, 13, 20, 27, 31
10jun3, 10, 17, 24
11jul1, 8, 15, 22, 29
12ago5, 12, 19, 26
13set2, 7, 9, 16, 23, 30
14out7, 12, 14, 21, 28
15nov2, 4, 11, 15, 18, 25
16dez2, 9, 16, 23, 25, 30
************************************

<tbody>
</tbody>


2) Now, create the names below:

Dates - Refers to: =Sheet1!$A$2:$A$366
Holis - Refers to: =Sheet1!$B$2:$B$366
Start - Refers to: =Main!$B$1
End - Refers to: =Main!$B$2
Months - Refers to: =Main!$A$5:$A$16 (for the 12 months of 2018)
SEMonths - Refers to: =(Dates>=Start)*(Dates<=End)*(Holis<>0)*MONTH(Dates)
DaysMonth - Refers to:

=IF(Dates>=Start,IF(Dates<=End,IF(Holis<>0,IF(MONTH(Dates)=MONTH(INDEX(Months,ROW()-ROW(Main!$A$5)+1)&"/"&YEAR(Start)),DAY(Dates)))))

3) Put the formula below in A5 in the sheet Main and copy down until the cell A16:

=IFERROR(TEXT(INDEX(MONTH(Dates),AGGREGATE(15,6,MATCH(ROW(INDIRECT("1:12")),
SEMonths,0),ROWS(A$5:A5)))&"/"&YEAR(Start),"mmm"),"")


4) Put the formula below in B5 in the sheet Main and copy down until the cell B16:

=IF(A5="","",SMALL(DaysMonth,1)&IFERROR(", "&SMALL(DaysMonth,2),"")&IFERROR(", "&SMALL(DaysMonth,3),"")&
IFERROR(", "&SMALL(DaysMonth,4),"")&IFERROR(", "&SMALL(DaysMonth,5),"")&IFERROR(", "&SMALL(DaysMonth,6),"")&
IFERROR(", "&SMALL(DaysMonth,7),"")&IFERROR(", "&SMALL(DaysMonth,8),"")&IFERROR(", "&SMALL(DaysMonth,9),""))


Ps1: if you think you need more days in each month, so edit the formula above.

Ps2: the holidays in the sheets are for my country.

I hope this helps.

Markmzz
 
Upvote 0
If you don't have Aggregate function, you can try this:

1) Create the name below:

SEMonths - Refers to: =IF(Dates>=Start,IF(Dates<=End,IF(Holis<>0,MONTH(Dates))))

2) Put the array formula (use Ctrl+Shift+Enter to the formula) below in B5 in the sheet Main and copy down until the cell B16:

=IFERROR(TEXT(INDEX(MONTH(Dates),SMALL(MATCH(ROW(INDIRECT("1:12")),
SEMonths,0),ROWS(A$5:A5)))&"/"&YEAR(Start),"mmm"),"")

Markmzz
 
Last edited:
Upvote 0
If you have Excel 2016 then you can use TEXTJOIN something like this:


Book1
AB
1DateHoliday Remarks
201-Jan-20180
302-Jan-20180
403-Jan-20180
504-Jan-20180
605-Jan-20180
706-Jan-20180
807-Jan-2018Sunday
908-Jan-20180
1009-Jan-20180
1110-Jan-20180
1211-Jan-20180
1312-Jan-20180
1413-Jan-20180
1514-Jan-2018Sunday
1615-Jan-20180
1716-Jan-20180
1817-Jan-20180
1918-Jan-20180
2019-Jan-20180
2120-Jan-20180
2221-Jan-2018Sunday
2322-Jan-20180
2423-Jan-20180
2524-Jan-20180
2625-Jan-20180
2726-Jan-2018Republic Day
2827-Jan-20180
2928-Jan-2018Sunday
Calendar



Book1
AB
1Start Date:01-Jan-2018
2End Date:31-Mar-2018
3
4MonthsHolidays
5Jan7,14,21,26,28
6Feb4,11,18,25
7Mar4,11,18,25
8
9
10
11
12
13
14
15
16
Holiday List
Cell Formulas
RangeFormula
A5=DATE(YEAR($B$1),MONTH($B$1),1)
A6=IF($A5="","",IF(EOMONTH($A5,0)+1>$B$2,"",EOMONTH($A5,0)+1))
B5{=TEXTJOIN(",",TRUE,IF(Calendar!$A$2:$A$367<$B$1,"",IF(Calendar!$A$2:$A$367>$B$2,"",IF(Calendar!$B$2:$B$367=0,"",IF($A5="","",IF(MONTH(Calendar!$A$2:$A$367)<>MONTH($A5),"",DAY(Calendar!$A$2:$A$367)))))))}
B6{=TEXTJOIN(",",TRUE,IF(Calendar!$A$2:$A$367<$B$1,"",IF(Calendar!$A$2:$A$367>$B$2,"",IF(Calendar!$B$2:$B$367=0,"",IF($A6="","",IF(MONTH(Calendar!$A$2:$A$367)<>MONTH($A6),"",DAY(Calendar!$A$2:$A$367)))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


Copy formula in A6 down to A16. Copy formula in B6 down to B16.

WBD
 
Upvote 0
Another way (with the layout of the post #2):

1) Create the names below:

Dates - Refers to: =Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(8^7,Sheet1!$A:$A,1))
Holis - Refers to: =Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(8^7,Sheet1!$A:$A,1))
Start - Refers to: =Main!$B$1
End - Refers to: =Main!$B$2
Months - Refers to: =Main!$A$5:INDEX(Main!$A:$A,MATCH(8^7,Main!$A:$A,1))
DaysMonth - Refers to: =IF(DATE(YEAR(Dates),MONTH(Dates),1)=INDEX(Months,ROW()-ROW(INDEX(Months,1))+1),IF(Holis<>0,DAY(Dates)))

2) Put the formula below in A5 in the sheet Main and copy down:

=IF((DATEDIF(Start,End,"m")+1)>=ROWS(A$5:A5),EDATE(Start,ROWS(A$5:A5)-1),"")

4) Format the cell B5 with the custom format mmm/yy and put the formula below in B5 in the sheet Main and copy down:

=IF(A5="","",SMALL(DaysMonth,1)&IFERROR(", "&SMALL(DaysMonth,2),"")&IFERROR(", "&SMALL(DaysMonth,3),"")&
IFERROR(", "&SMALL(DaysMonth,4),"")&IFERROR(", "&SMALL(DaysMonth,5),"")&IFERROR(", "&SMALL(DaysMonth,6),"")&
IFERROR(", "&SMALL(DaysMonth,7),"")&IFERROR(", "&SMALL(DaysMonth,8),"")&IFERROR(", "&SMALL(DaysMonth,9),""))


ABCD
1Start01/jan/18Sheet
2End31/mar/19Main
3
4MonthsHolidays
5jan/20181, 7, 14, 21, 28
6fev/20184, 11, 13, 18, 25
7mar/20184, 11, 18, 25, 30
8abr/20181, 8, 15, 21, 22, 29
9mai/20181, 6, 13, 20, 27, 31
10jun/20183, 10, 17, 24
11jul/20181, 8, 15, 22, 29
12ago/20185, 12, 19, 26
13set/20182, 7, 9, 16, 23, 30
14out/20187, 12, 14, 21, 28
15nov/20182, 4, 11, 15, 18, 25
16dez/20182, 9, 16, 23, 25, 30
17jan/20191, 6, 13, 20, 27
18fev/20193, 10, 17, 24
19mar/20193, 5, 10, 17, 24, 31
************************************

<tbody>
</tbody>


Markmzz
 
Upvote 0
Dear Markmzz,
Thanks a lot for the solution. I don't need the holidays of the whole year at a time. The Start Date and the End dates are variable.

e.g.
Start Date: 08-Jan-2018
End Date: 25-Feb-2018

OR
Start Date: 08-Jan-2018
End Date: 20-Mar-2018

I want only those holidays which fall between Start Date and the End Date, on month-wise basis. I will keep 3 rows x 2 columns reserved for the output assuming that not more than 3 months fall between Start Date and End Date.
 
Upvote 0
Dear Markmzz,
Thanks a lot for the solution. I don't need the holidays of the whole year at a time. The Start Date and the End dates are variable.

e.g.
Start Date: 08-Jan-2018
End Date: 25-Feb-2018

OR
Start Date: 08-Jan-2018
End Date: 20-Mar-2018

I want only those holidays which fall between Start Date and the End Date, on month-wise basis. I will keep 3 rows x 2 columns reserved for the output assuming that not more than 3 months fall between Start Date and End Date.

Did you try my suggestion of post #2?

Look at this:

ABCD
1Start08/jan/18Sheet
2End25/fev/18Main
3
4MonthsHolidays
5jan14, 21, 28
6fev4, 11, 13, 18, 25
7
************************************

<tbody>
</tbody>

And this:

ABCD
1Start08/jan/18Sheet
2End20/mar/18Main
3
4MonthsHolidays
5jan14, 21, 28
6fev4, 11, 13, 18, 25
7mar4, 11, 18
************************************

<tbody>
</tbody>


Markmzz
 
Upvote 0
Dear Markmzz,
Thanks a lot for the solution. I don't need the holidays of the whole year at a time. The Start Date and the End dates are variable.

e.g.
Start Date: 08-Jan-2018
End Date: 25-Feb-2018

OR
Start Date: 08-Jan-2018
End Date: 20-Mar-2018

I want only those holidays which fall between Start Date and the End Date, on month-wise basis. I will keep 3 rows x 2 columns reserved for the output assuming that not more than 3 months fall between Start Date and End Date.

Here is a small modification in my suggestion of the post #2:

Lets go:

1) Create two blank sheets: Main and Sheet1. Put your Holidays Data in the rage A2:B366 (for 2018 - or more if you want) of the sheet Sheet1 and in A1, A2, A4 and B4 of the sheet Main put the texts Start:, End:, Months and Holidays.

2) Now, create the names below:

Dates - Refers to: =Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(8^7,Sheet1!$A:$A,1))
Holis - Refers to: =Sheet1!$B$2:INDEX(Sheet1!$B:$B,MATCH(8^7,Sheet1!$A:$A,1))
Start - Refers to: =Main!$B$1
End - Refers to: =Main!$B$2
Months - Refers to: =Main!$A$5:$A$7 (like you said: only 03 months)
SEMonths
- Refers to: =IFERROR(MATCH(ROW(INDIRECT("1:12")),(Dates>=Start)*(Dates<=End)*(Holis<>0)*MONTH(Dates),0),FALSE)
DaysMonth
- Refers to: =IF(Dates>=Start,IF(Dates<=End,IF(Holis<>0,IF(MONTH(Dates)=MONTH(INDEX(Months,ROW()-ROW(INDEX(Months,1))+1)&"/"&YEAR(Start)),DAY(Dates)))))

3) Put the formula below in A5 in the sheet Main and copy down until A7 (like you said: only 03 months):

=IFERROR(TEXT(INDEX(MONTH(Dates),SMALL(SEMonths,ROWS(A$5:A5)))&"/"&YEAR(Start),"mmm"),"")

4) Put the formula below in B5 in the sheet Main and copy down until B7 (like you said: only 03 months):

=IF(A5="","",SMALL(DaysMonth,1)&IFERROR(", "&SMALL(DaysMonth,2),"")&IFERROR(", "&SMALL(DaysMonth,3),"")&
IFERROR(", "&SMALL(DaysMonth,4),"")&IFERROR(", "&SMALL(DaysMonth,5),"")&IFERROR(", "&SMALL(DaysMonth,6),"")&
IFERROR(", "&SMALL(DaysMonth,7),"")&IFERROR(", "&SMALL(DaysMonth,8),"")&IFERROR(", "&SMALL(DaysMonth,9),""))

Ps1: if you think you need more days in each month, so edit the formula above.
Ps2: the holidays in the sheets are for my country.

I hope this helps.

Markmzz
 
Upvote 0
Here is a small modification in my suggestion of the post #2:

Lets go:

1) Create two blank sheets: Main and Sheet1. Put your Holidays Data in the rage A2:B366 (for 2018 - or more if you want) of the sheet Sheet1 and in A1, A2, A4 and B4 of the sheet Main put the texts Start:, End:, Months and Holidays.

2) Now, create the names below:

Dates - Refers to: =Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(8^7,Sheet1!$A:$A,1))
Holis - Refers to: =Sheet1!$B$2:INDEX(Sheet1!$B:$B,MATCH(8^7,Sheet1!$A:$A,1))
Start - Refers to: =Main!$B$1
End - Refers to: =Main!$B$2
Months - Refers to: =Main!$A$5:$A$7 (like you said: only 03 months)
SEMonths
- Refers to: =IFERROR(MATCH(ROW(INDIRECT("1:12")),(Dates>=Start)*(Dates<=End)*(Holis<>0)*MONTH(Dates),0),FALSE)
DaysMonth
- Refers to: =IF(Dates>=Start,IF(Dates<=End,IF(Holis<>0,IF(MONTH(Dates)=MONTH(INDEX(Months,ROW()-ROW(INDEX(Months,1))+1)&"/"&YEAR(Start)),DAY(Dates)))))

3) Put the formula below in A5 in the sheet Main and copy down until A7 (like you said: only 03 months):

=IFERROR(TEXT(INDEX(MONTH(Dates),SMALL(SEMonths,ROWS(A$5:A5)))&"/"&YEAR(Start),"mmm"),"")

4) Put the formula below in B5 in the sheet Main and copy down until B7 (like you said: only 03 months):

=IF(A5="","",SMALL(DaysMonth,1)&IFERROR(", "&SMALL(DaysMonth,2),"")&IFERROR(", "&SMALL(DaysMonth,3),"")&
IFERROR(", "&SMALL(DaysMonth,4),"")&IFERROR(", "&SMALL(DaysMonth,5),"")&IFERROR(", "&SMALL(DaysMonth,6),"")&
IFERROR(", "&SMALL(DaysMonth,7),"")&IFERROR(", "&SMALL(DaysMonth,8),"")&IFERROR(", "&SMALL(DaysMonth,9),""))

Ps1: if you think you need more days in each month, so edit the formula above.
Ps2: the holidays in the sheets are for my country.

I hope this helps.

Markmzz


The formula on A5 is returning blank (#NUM error when IFERROR is removed).
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,749
Members
449,186
Latest member
HBryant

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