Lookup value for a date in a date range and return value

ahmedanis7

New Member
Joined
Sep 21, 2014
Messages
3
Dear Experts,

This is my first post and will be obliged for the help.

I have data in two sheets.

The first sheet "Day" contains following columns - Emp Number, Date.

The second sheet "Absence" has following columns - Emp Number , Start Date, End Date, Leave type

I need a formula or macro which will check if the Date as per the sheet "Day" falls between the start date and end date in sheet "Absence"and if yes, the type of leave is updated in Sheet "Day" .

Note- there could be multiple entries for same employee in the absence sheet.

Sheet "Day"

EMP NO DATE RESULT REQUIRED
123 15/09/2014 SICK LEAVE
123 17/09/2014 --
333 05/09/2014 --
333 10/09/2014 Annual Leave
333 12/09/2014 Annual Leave
333 16/09/2014 ---
333 18/09/2014 Sick Leave
333 19/09/2014 Sick Leave


Sheet "Absence"

Emp No Start Dtae End Date Leave
123 15/09/2014 15/09/2014 Sick Leave
333 10/09/2014 14/09/2014 Annual Leave
333 18/09/2014 20/09/2014 Sick Leave

Thanks.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
In C2 on sheet "day":

=IFERROR(INDEX(Absence!$D$2:$D$4;MATCH(1;IF(Absence!$A$2:$A$4=A2;IF(B2>=Absence!$B$2:$B$4;IF(B2<=Absence!$C$2:$C$4;1)));0));"- -")

Enter with CTRL + SHIFT + ENTER
 
Upvote 0
Thanks. It worked. </SPAN>
C:\Users\anis\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif
</SPAN>.

There is so much to learn !!!

I had to replace the semi-colons with commas to make the formaula work. Is it got to do with the Excel Version I am using??</SPAN>
 
Upvote 0
Thanks. It worked.
C:\Users\anis\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif
.

There is so much to learn !!!

I had to replace the semi-colons with commas to make the formaula work. Is it got to do with the Excel Version I am using??

Glad it worked!

the issue with semi-colons and commas is caused by the regional settings on your computer.
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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