Hello Excel experts!
I consider myself an expert user of Excel but I really got stuck on this problem . I prefer a solution with built-in formulas but if that isn't possible a VBA solution is fine.
I have one table (the Rating table) where I occasionally put in data that is event driven: e.g. a change in a banks credit rating. That happens once in a while and I am recording the bank, actual date that the credit rating was changed, and the credit rating. In the second table (the Lookup table) I have daily cash balance with each bank and would like to tag each balance with the relevant rating of that bank. This means that I would like to search for the row in the Rating table that matches the bank and the date that is closest i.e. equal to or less than the cash balance date. Please see the tables below.
Rating Table
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Bank[/TD]
[TD]Date[/TD]
[TD]Rating[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]01/05/2014[/TD]
[TD]A+[/TD]
[/TR]
[TR]
[TD]RBS[/TD]
[TD]01/05/2014[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]05/03/2014[/TD]
[TD]AA[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]08/30/2014[/TD]
[TD]A-[/TD]
[/TR]
[TR]
[TD]RBS[/TD]
[TD]08/30/2014[/TD]
[TD]A-[/TD]
[/TR]
</tbody>[/TABLE]
Lookup table
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Cash balance[/TD]
[TD]Bank[/TD]
[TD]Rating[/TD]
[TD]Answer:[/TD]
[/TR]
[TR]
[TD]03/31/2014[/TD]
[TD]1000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]A+[/TD]
[/TR]
[TR]
[TD]03/31/2014[/TD]
[TD]2000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]06/30/2014[/TD]
[TD]3000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]AA[/TD]
[/TR]
[TR]
[TD]06/30/2014[/TD]
[TD]4000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]09/30/2014[/TD]
[TD]5000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]A-[/TD]
[/TR]
[TR]
[TD]09/30/2014[/TD]
[TD]6000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A-[/TD]
[/TR]
</tbody>[/TABLE]
I consider myself an expert user of Excel but I really got stuck on this problem . I prefer a solution with built-in formulas but if that isn't possible a VBA solution is fine.
I have one table (the Rating table) where I occasionally put in data that is event driven: e.g. a change in a banks credit rating. That happens once in a while and I am recording the bank, actual date that the credit rating was changed, and the credit rating. In the second table (the Lookup table) I have daily cash balance with each bank and would like to tag each balance with the relevant rating of that bank. This means that I would like to search for the row in the Rating table that matches the bank and the date that is closest i.e. equal to or less than the cash balance date. Please see the tables below.
Rating Table
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Bank[/TD]
[TD]Date[/TD]
[TD]Rating[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]01/05/2014[/TD]
[TD]A+[/TD]
[/TR]
[TR]
[TD]RBS[/TD]
[TD]01/05/2014[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]05/03/2014[/TD]
[TD]AA[/TD]
[/TR]
[TR]
[TD]Citibank[/TD]
[TD]08/30/2014[/TD]
[TD]A-[/TD]
[/TR]
[TR]
[TD]RBS[/TD]
[TD]08/30/2014[/TD]
[TD]A-[/TD]
[/TR]
</tbody>[/TABLE]
Lookup table
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Cash balance[/TD]
[TD]Bank[/TD]
[TD]Rating[/TD]
[TD]Answer:[/TD]
[/TR]
[TR]
[TD]03/31/2014[/TD]
[TD]1000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]A+[/TD]
[/TR]
[TR]
[TD]03/31/2014[/TD]
[TD]2000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]06/30/2014[/TD]
[TD]3000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]AA[/TD]
[/TR]
[TR]
[TD]06/30/2014[/TD]
[TD]4000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]09/30/2014[/TD]
[TD]5000[/TD]
[TD]Citibank[/TD]
[TD]Formula here...[/TD]
[TD]A-[/TD]
[/TR]
[TR]
[TD]09/30/2014[/TD]
[TD]6000[/TD]
[TD]RBS[/TD]
[TD]Formula here...[/TD]
[TD]A-[/TD]
[/TR]
</tbody>[/TABLE]