How do I output a client name based on a year range and ID code for that year?

kmprice710

Board Regular
Joined
Jan 8, 2014
Messages
87
Office Version
  1. 2019
Platform
  1. Windows
I have a bunch of clients on a list with the year they purchased the product:

[TABLE="width: 500"]
<tbody>[TR]
[TD]ID
[/TD]
[TD]Year
[/TD]
[TD]Client
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]2005
[/TD]
[TD]?
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]2004
[/TD]
[TD]?
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]2002
[/TD]
[TD]?
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]2006
[/TD]
[TD]?
[/TD]
[/TR]
</tbody>[/TABLE]

I have a list of ID codes with year ranges:

[TABLE="width: 500"]
<tbody>[TR]
[TD]ID
[/TD]
[TD]From
[/TD]
[TD]To
[/TD]
[TD]Client
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]2001
[/TD]
[TD]2002
[/TD]
[TD]Barry
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]2003
[/TD]
[TD]2004
[/TD]
[TD]Barry-Elwood
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]2005
[/TD]
[TD]2006
[/TD]
[TD]Barry-Yearling
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]2001
[/TD]
[TD]2002
[/TD]
[TD]Todd
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]2003
[/TD]
[TD]2004
[/TD]
[TD]Todd-Young
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]2001
[/TD]
[TD]2002
[/TD]
[TD]Smith
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]2003
[/TD]
[TD]2004
[/TD]
[TD]Smith-Armour
[/TD]
[/TR]
</tbody>[/TABLE]

How do I write a formula to output the client names given the ID code and year ranges?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I have a bunch of clients on a list with the year they purchased the product:

[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Year[/TD]
[TD]Client[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2005[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2004[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]2002[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2006[/TD]
[TD]?[/TD]
[/TR]
</tbody>[/TABLE]

I have a list of ID codes with year ranges:

[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]From[/TD]
[TD]To[/TD]
[TD]Client[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2001[/TD]
[TD]2002[/TD]
[TD]Barry[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2003[/TD]
[TD]2004[/TD]
[TD]Barry-Elwood[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2005[/TD]
[TD]2006[/TD]
[TD]Barry-Yearling[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2001[/TD]
[TD]2002[/TD]
[TD]Todd[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2003[/TD]
[TD]2004[/TD]
[TD]Todd-Young[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]2001[/TD]
[TD]2002[/TD]
[TD]Smith[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]2003[/TD]
[TD]2004[/TD]
[TD]Smith-Armour[/TD]
[/TR]
</tbody>[/TABLE]

How do I write a formula to output the client names given the ID code and year ranges?

I tried lookup and sumproduct and couldn't get it to work. Any ideas?
 
Upvote 0
I tried lookup and sumproduct and couldn't get it to work. Any ideas?
If I'm understanding your goal correctly, assuming A1:C5 is the top table and A7:D14 is the bottom table, you can put this formula in place of the ?:
=INDEX($D$8:$D$14,IF(ISEVEN(B2),MATCH(A2&B2,$A$8:$A$14&$C$8:$C$14),MATCH(A2&B2,$A$8:$A$14&$B$8:$B$14,0)))
It has to be an array formula, so while still in the cell, press Ctrl+Shift+Enter which will result in this:
{=INDEX($D$8:$D$14,IF(ISEVEN(B2),MATCH(A2&B2,$A$8:$A$14&$C$8:$C$14),MATCH(A2&B2,$A$8:$A$14&$B$8:$B$14,0)))}
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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