Formula to return last value for X date

Marklarbear

Board Regular
Joined
Nov 6, 2003
Messages
112
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Firstly - apologies, I can no longer use xl2bb as IT have changed security settings and it now shows as 'Microsoft has blocked macros from running because the source of this file is untrusted'.

I have columns of values that I update non-frequently for weeks of the year. What I would like to do is build a formula so that on another sheet it returns the last value of data for the corresponding date.

In the attached screenshot, dates are in column B, every so often i would add updated values in the next column across. On another sheet, i would have a list of dates and need the latest value to populate (I have represented this in columns K & L). I'm looking for a formula to put in column L to return the last value for the corresponding date in column K.

Hopefully this all makes sense?

i've tried playing with Xlookup... but with no success....
 

Attachments

  • Screenshot 2022-09-05 111948.png
    Screenshot 2022-09-05 111948.png
    50 KB · Views: 14

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
In L42:
Code:
=LOOKUP(2,1/(INDEX($C$40:$H$65,MATCH(K42,$B$40:$B$65),)<>""),INDEX($C$40:$H$65,MATCH(K42,$B$40:$B$65),))
 
Upvote 0
Given that the data is numeric, you could use this much shorter & more efficient formula.

Excel Formula:
=LOOKUP(9.9E+307,FILTER(C$40:H$65,B$40:B$65=K42))


I can no longer use xl2bb as IT have changed security settings
You can just copy/paste a range (smallish) from your sheet directly into your post (& identify what columns/rows it is). That way at least we can still copy the data to test with.
Small example where I have hidden cols I:J to keep it a bit smaller

Col/RowBCDEFGHKL
40​
13/06/2022​
503​
837​
466​
620​
41​
20/06/2022​
557​
129​
931​
352​
42​
27/06/2022​
630​
138​
120​
748​
5/09/2022​
854​
43​
4/07/2022​
628​
628​
154​
324​
12/09/2022​
840​
44​
11/07/2022​
164​
170​
494​
361​
19/09/2022​
831​
45​
18/07/2022​
595​
853​
312​
819​
26/09/2022​
973​
46​
25/07/2022​
611​
342​
146​
934​
3/10/2022​
213​
47​
1/08/2022​
939​
880​
907​
771​
10/10/2022​
606​
48​
8/08/2022​
341​
729​
181​
865​
17/10/2022​
932​
49​
15/08/2022​
628​
348​
895​
814​
24/10/2022​
865​
50​
22/08/2022​
971​
596​
394​
557​
31/10/2022​
309​
51​
29/08/2022​
209​
722​
844​
431​
7/11/2022​
439​
52​
5/09/2022​
699​
451​
977​
854​
53​
12/09/2022​
831​
639​
652​
840​
 
Last edited:
Upvote 0
Solution
'Microsoft has blocked macros from running because the source of this file is untrusted'.
Please see if the below link to a response to a post with the same issue yesterday helps
 
Upvote 0
how does the '9.9E+307,FILTER' part of the formula work?
FILTER(C$40:H$65,B$40:B$65=K42)
This part simply returns the row of the data (columns C:H) where the date matches. So for the sample data I posted above, for the formula in cell L42 it would return this (for 5/09/2022)
22 09 05.xlsm
CDEFGH
52699451977854
Last Value


Then the LOOKUP looks for 9.99E307 which is a very big number (99 followed by 306 zeros) in that range. When LOOKUP cannot find the exact number it is looking for, it returns the last number that it can find. In that case 854.
 
Upvote 0
FILTER(C$40:H$65,B$40:B$65=K42)
This part simply returns the row of the data (columns C:H) where the date matches. So for the sample data I posted above, for the formula in cell L42 it would return this (for 5/09/2022)
22 09 05.xlsm
CDEFGH
52699451977854
Last Value


Then the LOOKUP looks for 9.99E307 which is a very big number (99 followed by 306 zeros) in that range. When LOOKUP cannot find the exact number it is looking for, it returns the last number that it can find. In that case 854.
Cheers Peter - that makes sense in my brain :)
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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