I need to lookup for nearest max data and nearest min date and return apprioprate code (code on nearest min date and code nearest max date date) based on two parameters
can anyone help me out?
based on Sheet 2 I need to return CODE in Sheet 1
[TABLE="width: 954"]
<tbody>[TR]
[TD]Sheet 1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD="colspan: 2"]EXAMPLE DATE
[/TD]
[TD="colspan: 2"]EXAMPLE CODE
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Name
[/TD]
[TD]DATE
[/TD]
[TD]Code on nearest Min date
[/TD]
[TD]Code on nearest Max date
[/TD]
[TD]expected code on min date to be returned
[/TD]
[TD]expected code max date to be returned
[/TD]
[TD]expected code on min date to be returned
[/TD]
[TD]expected code max date to be returned
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Apple
[/TD]
[TD]01-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]02-01-2018
[/TD]
[TD]NA
[/TD]
[TD]123
[/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Apple
[/TD]
[TD]03-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]03-01-2018
[/TD]
[TD]03-01-2018
[/TD]
[TD]56
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Orange
[/TD]
[TD]08-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]NA
[/TD]
[TD]09-01-2018
[/TD]
[TD]NA
[/TD]
[TD]2365
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]banana
[/TD]
[TD]11-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]10-01-2018
[/TD]
[TD]12-01-2018
[/TD]
[TD]3241
[/TD]
[TD]236
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 399"]
<tbody>[TR]
[TD]Sheet 2
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]c
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Name
[/TD]
[TD]Date
[/TD]
[TD]CODE
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Apple
[/TD]
[TD]02-01-2018
[/TD]
[TD]123
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Apple
[/TD]
[TD]03-01-2018
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Orange
[/TD]
[TD]07-01-2018
[/TD]
[TD]987
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Orange
[/TD]
[TD]09-01-2018
[/TD]
[TD]2365
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]Orange
[/TD]
[TD]10-01-2018
[/TD]
[TD]698
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]Banana
[/TD]
[TD]10-01-2018
[/TD]
[TD]1478
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]Banana
[/TD]
[TD]12-01-2018
[/TD]
[TD]3241
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]Banana
[/TD]
[TD]13-01-2018
[/TD]
[TD]236
[/TD]
[/TR]
</tbody>[/TABLE]
can anyone help me out?
based on Sheet 2 I need to return CODE in Sheet 1
[TABLE="width: 954"]
<tbody>[TR]
[TD]Sheet 1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD="colspan: 2"]EXAMPLE DATE
[/TD]
[TD="colspan: 2"]EXAMPLE CODE
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Name
[/TD]
[TD]DATE
[/TD]
[TD]Code on nearest Min date
[/TD]
[TD]Code on nearest Max date
[/TD]
[TD]expected code on min date to be returned
[/TD]
[TD]expected code max date to be returned
[/TD]
[TD]expected code on min date to be returned
[/TD]
[TD]expected code max date to be returned
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Apple
[/TD]
[TD]01-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]02-01-2018
[/TD]
[TD]NA
[/TD]
[TD]123
[/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Apple
[/TD]
[TD]03-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]03-01-2018
[/TD]
[TD]03-01-2018
[/TD]
[TD]56
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Orange
[/TD]
[TD]08-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]NA
[/TD]
[TD]09-01-2018
[/TD]
[TD]NA
[/TD]
[TD]2365
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]banana
[/TD]
[TD]11-01-2018
[/TD]
[TD]?
[/TD]
[TD]?
[/TD]
[TD]10-01-2018
[/TD]
[TD]12-01-2018
[/TD]
[TD]3241
[/TD]
[TD]236
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 399"]
<tbody>[TR]
[TD]Sheet 2
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]c
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Name
[/TD]
[TD]Date
[/TD]
[TD]CODE
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Apple
[/TD]
[TD]02-01-2018
[/TD]
[TD]123
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Apple
[/TD]
[TD]03-01-2018
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Orange
[/TD]
[TD]07-01-2018
[/TD]
[TD]987
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Orange
[/TD]
[TD]09-01-2018
[/TD]
[TD]2365
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]Orange
[/TD]
[TD]10-01-2018
[/TD]
[TD]698
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]Banana
[/TD]
[TD]10-01-2018
[/TD]
[TD]1478
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]Banana
[/TD]
[TD]12-01-2018
[/TD]
[TD]3241
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]Banana
[/TD]
[TD]13-01-2018
[/TD]
[TD]236
[/TD]
[/TR]
</tbody>[/TABLE]