Hi,
I'm trying to have a formula to return the 5th last date of the month after deducting the off days/PH & closing date which we list in a table like below:-
[TABLE="width: 238"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Date[/TD]
[TD]*Event/PH[/TD]
[TD]Dept[/TD]
[/TR]
[TR]
[TD]1/1/2014[/TD]
[TD]New Year[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]5/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]8/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]11/1/2014[/TD]
[TD]School Holidays[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]12/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]13/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]18/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]19/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]23/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]24/1/2014[/TD]
[TD]Thaipusam[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]26/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]28/1/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]29/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]31/1/2014[/TD]
[TD]CNY[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]2/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]5/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]20/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]21/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]23/2/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]28/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]OS[/TD]
[/TR]
[TR]
[TD]3/3/2014[/TD]
[TD]Whateva[/TD]
[TD]NB[/TD]
[/TR]
[TR]
[TD]3/3/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6/3/2014[/TD]
[TD]Whateva[/TD]
[TD]NB[/TD]
[/TR]
[TR]
[TD]6/3/2014[/TD]
[TD]AidilAdha[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]9/3/2014[/TD]
[TD]Whateva[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]12/3/2014[/TD]
[TD]Whateva[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]20/3/2014[/TD]
[TD]Whateva[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]22/3/2014[/TD]
[TD]Hari Raya[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]25/3/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]28/6/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]26/11/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
Basically, we will use formula like below to achieve this :-
{=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",$A$11:$A$1098,0))}
cell C1=Year
cell T2=Month
Col A = Dates
However, my situation right now is that the range $A$11:$A$1098 would need to be based on criteria in col C ==> Dept name or blank. This is to ensure the 5th last working date for the particular staff of the respective dept will not be compromised by deducting those dates which are not the dept off-days or closing date. This is due to the fact that our company has non-fixed off-days and production closing date for each dept. This 5th last working date is significant for our monthly incentive calculation. Those blanks one shud indicate that the holiday is for all depts. Hence, my holiday dates range for the particular dept must include both values.
I tried several formulas like below:-
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF("POS"=$C$11:$C$1098,$A$11:$A$1098,0))
Result : Works BUT it doesn't count for Dept value = blank
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(" "=$C$11:$C$1098,$A$11:$A$1098,0)) << with space
Result : Works BUT it doesn't count for Dept value = POS or NB or CLM and weird to have the result as I didn't put any space for the blank dept name
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(OR("POS"=$D$11:$D$1098,""=$D$11:$D$1098),$A$11:$A$1098,0))
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(MATCH(1,("POS"=$D$11:$D$1098)+(""=$D$11:$D$1098),0),$A$11:$A$1098,0))
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(""=$C$11:$C$1098,$A$11:$A$1098,0)) << without space
All above returned error #VALUE!
FYI, the value from each cell in the table above is referenced from another worksheet.
Hopefully, anyone can help me on this as I have tried over 2 weeks but couldn't find solution.
I'm trying to have a formula to return the 5th last date of the month after deducting the off days/PH & closing date which we list in a table like below:-
[TABLE="width: 238"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Date[/TD]
[TD]*Event/PH[/TD]
[TD]Dept[/TD]
[/TR]
[TR]
[TD]1/1/2014[/TD]
[TD]New Year[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]5/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]8/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]11/1/2014[/TD]
[TD]School Holidays[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]12/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]13/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]18/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]19/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]23/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]24/1/2014[/TD]
[TD]Thaipusam[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]26/1/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]28/1/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]29/1/2014[/TD]
[TD]Off-Day[/TD]
[TD]CLM[/TD]
[/TR]
[TR]
[TD]31/1/2014[/TD]
[TD]CNY[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]2/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]5/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]20/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]21/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]23/2/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]28/2/2014[/TD]
[TD]Off-Day[/TD]
[TD]OS[/TD]
[/TR]
[TR]
[TD]3/3/2014[/TD]
[TD]Whateva[/TD]
[TD]NB[/TD]
[/TR]
[TR]
[TD]3/3/2014[/TD]
[TD]Off-Day[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6/3/2014[/TD]
[TD]Whateva[/TD]
[TD]NB[/TD]
[/TR]
[TR]
[TD]6/3/2014[/TD]
[TD]AidilAdha[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]9/3/2014[/TD]
[TD]Whateva[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]12/3/2014[/TD]
[TD]Whateva[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]20/3/2014[/TD]
[TD]Whateva[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]22/3/2014[/TD]
[TD]Hari Raya[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]25/3/2014[/TD]
[TD]Off-Day[/TD]
[TD]POS[/TD]
[/TR]
[TR]
[TD]28/6/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]26/11/2014[/TD]
[TD]Closing[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
Basically, we will use formula like below to achieve this :-
{=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",$A$11:$A$1098,0))}
cell C1=Year
cell T2=Month
Col A = Dates
However, my situation right now is that the range $A$11:$A$1098 would need to be based on criteria in col C ==> Dept name or blank. This is to ensure the 5th last working date for the particular staff of the respective dept will not be compromised by deducting those dates which are not the dept off-days or closing date. This is due to the fact that our company has non-fixed off-days and production closing date for each dept. This 5th last working date is significant for our monthly incentive calculation. Those blanks one shud indicate that the holiday is for all depts. Hence, my holiday dates range for the particular dept must include both values.
I tried several formulas like below:-
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF("POS"=$C$11:$C$1098,$A$11:$A$1098,0))
Result : Works BUT it doesn't count for Dept value = blank
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(" "=$C$11:$C$1098,$A$11:$A$1098,0)) << with space
Result : Works BUT it doesn't count for Dept value = POS or NB or CLM and weird to have the result as I didn't put any space for the blank dept name
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(OR("POS"=$D$11:$D$1098,""=$D$11:$D$1098),$A$11:$A$1098,0))
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(MATCH(1,("POS"=$D$11:$D$1098)+(""=$D$11:$D$1098),0),$A$11:$A$1098,0))
=WORKDAY.INTL(DATE($C$1,MONTH(DATEVALUE($T$2&" 1"))+1,1),-5,"0000000",IF(""=$C$11:$C$1098,$A$11:$A$1098,0)) << without space
All above returned error #VALUE!
FYI, the value from each cell in the table above is referenced from another worksheet.
Hopefully, anyone can help me on this as I have tried over 2 weeks but couldn't find solution.