INDEX MATCH to return values based on date comparison between 2 worksheets

curious1

Board Regular
Joined
Jul 22, 2005
Messages
58
Office Version
  1. 365
Platform
  1. Windows
Hi, struggling with producing an INDEX MATCH formula that will achieve the following:
For each Name in WS1, if its Date < 365 days from the Date of the matching Name in WS2, return "N" in WS1 Col C, otherwise return the value in WS2 Col C corresponding to that Name.
The results should be WS1 Col C in the example below.
Book1
ABC
1NAMEDATENEW LABEL
2Name112/1/2021N
3Name212/2/2021N
4Name312/3/2021S
5Name412/4/2021N
6Name512/5/2021F
WS1

Book1
ABC
1NAMEDATELABEL
2Name11/20/2020N
3Name28/9/2021IP
4Name35/23/2019S
5Name49/1/2021F
6Name53/7/2020F
WS2

Any help is deeply appreciated!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
=INDEX('WS2'!$B$2:$B$6,MATCH('WS1'!A2,'WS2'!$A$2:$A$6,0))
will find the date in WS2

then you can take WS1 date away to get the number of days

Then use an IF()

Book1
ABCDEFGHIJKL
1NAMEDATENEW LABELFormulaDate WS2Days
2Name112/1/21NN1/20/20681WS1, if its Date < 365 days from the Date of the matching Name in WS2, return "N" in
3Name212/2/21NN8/9/21115
4Name312/3/21SS5/23/19925
5Name412/4/21NN1/9/21329
6Name512/5/21FF7/3/20520
7
8
WS1
Cell Formulas
RangeFormula
D2:D6D2=IF(B2-INDEX('WS2'!$B$2:$B$6,MATCH('WS1'!A2,'WS2'!$A$2:$A$6,0))<365,"N",INDEX('WS2'!$C$2:$C$6,MATCH('WS1'!A2,'WS2'!$A$2:$A$6,0)))
E2:E6E2=INDEX('WS2'!$B$2:$B$6,MATCH('WS1'!A2,'WS2'!$A$2:$A$6,0))
G2:G6G2=B2-E2


Book1
ABC
1NAMEDATELABEL
2Name11/20/20N
3Name28/9/21IP
4Name35/23/19S
5Name41/9/21F
6Name57/3/20F
WS2
 
Upvote 0
Solution
etaf: Thank you for the answer and the education! I did not have clarity on how to see and construct the solution correctly. I appreciated seeing your logic, which I applied to my actual data set to obtain the desired output. Worked! Then, ignoring the answer, I wrote an abstracted version of each INDEX/MATCH formula to help grasp what each needed to accomplish and nested those together into a conceptual formula. I then wrote the actual formula based on that summarization and it worked. I hope I will be able to "see" how to approach future problems given this example. Much appreciated!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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