0

the challenge is: if a Holiday Date ($F) falls in between (A2:B2, A3:B3,etc) I want to copy the the Holiday Name ($G to the associated reason column $D & the Count $H to the associated $C column)

example: Vacation '17 is on 10/15/17 for 5 days because it falls on 10/3/17 & 10/16/17 the data will be copied on the $C and $D columns... how can I do that??

enter image description here

3 Answers 3

1

You can use these two array formula (click Ctrl + Shift + Enter together):

From cell C2:

=IFERROR(INDEX($H$2:$H$11,SMALL(IF((A2<=$F$2:$F$11)*(B2>=$F$2:$F$11)>0,ROW($F$2:$F$11)-ROW($F$1),""),1)),0)

From cell D2:

=IFERROR(INDEX($G$2:$G$11,SMALL(IF((A2<=$F$2:$F$11)*(B2>=$F$2:$F$11)>0,ROW($F$2:$F$11)-ROW($F$1),""),1)),"")

What these two formulas do is to find the first match and return the value.

Also, I noticed that your C9 and D12 have different results than mine. Not sure what is wrong but I am guessing it is due to the sample data you have posted here. Anyway, try and let me know.

Sign up to request clarification or add additional context in comments.

5 Comments

that's amazing!!! THANK YOU very much for the help!! so couple of things: I noticed the same thing as you but $C is returning a count but it needs to return the value found in $H (my apologies if labels and my explanation are not clear) Also the only cells I get results are C8 & C9... all others are empty... -- Looking at the data, I can consolidate the dates that are close to each other - 12/31/2017 -> 1 + 1/1/2018 -> 1 to be one 12/31/2017 -> 2
I'm unsure but if you add just this portion (A2<=$F$2:$F$11)*(B2>=$F$2:$F$11) to a separate cell, Excel treats this as a 1:1 relationship. A2 -> F2, A3 - > F3... because after A12 I see #VALUE!
Just noticed that you didn't enter this as an array formula (click Ctrl + Shift + Enter altogether) and you should see the curly braces will be included in the formula (see my pic). Also, those ranges need to be adjusted based on your data input. I don't recommend to use whole column since it will slow things down but you can do so if you don't have much data in there.
yeah... I didn't understand what you meant but I got it working !! it's awesome... thank you very much !! ( the Ctrl+Shit+Enter needs to be pressed on the formula bar to make it an array.... for anyone else that's reading this)
Correct, and that is how you use an array formula. It is a powerful feature if you know how to use it.
0

Put this in C2 and copy across to D2, then copy down:

=IFERROR(INDEX(H$2:H$4, POWER(SQRT(MAX(IF($F$2:$F$4-$A2>=0, IF($F$2:$F$4-$B2<=0, ROW($F$2:$F$4)-ROW($F$1))))-1), 2)+1), "")

Comments

0

$C should have the value found in $H and $D should have the value found in $G

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.