return last populated cell based on lookup conditions

buroh

New Member
Joined
Jul 14, 2020
Messages
43
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I need some help with a formula which is not working the way I want it too.

I have columns with dates and rows with values, see below:
1667476073285.png


my current formula in column M is: =IFNA(LOOKUP(2,1/((Q10:DA10<>"")*(Q10:DA10<>"Y")),Q10:DA10),"")

What it currently does is pick up the last cell in the row which is not blank, but will ignore a cell which has Y as a value.

But what I also need the formula to do is to return the value of the last populated cell of the column which has todays date or any date before todays date.

for an example the cell of row 12 column M would be blank because the last populated cell is of a date in the future.
but the value in row 10 of column N would be P01 as that is the last populated cell of todays date.

I have tried to use IF function, xlookup function but all I get is spill or error, especially because the formula doesn't like the < symbol when looking up the value e.g. <TODAY(). The IF or OR formula doesn't want to work, I am not sure what to do, any suggestions would be helpful.

Thanks,
 

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.
How about
Excel Formula:
=IFNA(LOOKUP(2,1/((Q10:DA10<>"")*(Q10:DA10<>"Y")*(QA$6:DA$6<=Today())),Q10:DA10),"")
 
Upvote 0
How about
Excel Formula:
=IFNA(LOOKUP(2,1/((Q10:DA10<>"")*(Q10:DA10<>"Y")*(QA$6:DA$6<=Today())),Q10:DA10),"")
Hi, thank you, but did not work.

It still returned the value of the column with a date in the near future, it seemed to have ignored the DA$6:QA$6<=TODAY() part of the formula.

I did try using the OR function but didn't like that either.
 
Upvote 0
Check that your dates in row 6 are real dates & not text.
 
Upvote 0
What do you see if you change the format to General?
 
Upvote 0
That's fine, it's a real date.
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
That's fine, it's a real date.
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Thank you,

The add on will not work for me at work and IT are very hot on unverified add on's. I cannot find another way to upload my sheet.

okay I managed to get it to work, see below, thank you.
 
Last edited:
Upvote 0
sample sheet.xlsx
ABCDEFGHIJK
7Current RevCurrent Issue Date01/04/202201/05/202227/06/202201/08/202201/09/202230/09/202214/10/202225/11/202203/11/2022
8Stage 4Stage 2Stage 4Stage 2Stage 4Stage 4Stage 4Stage 4Stage 4
9SS01/09/2022SS
10P0103/11/2022P01
11P0201/09/2022P01P02
120 P01
13P0101/05/2022P01
14P0101/08/2022P01
15P0103/11/2022P01
16P0201/09/2022P01P02
17P01 P01
18P0414/10/2022P04
Sheet1
Cell Formulas
RangeFormula
B9:B18B9=IFNA(IF(OR(XLOOKUP(A9,$C9:$K9,$C$7:$K$7,,0)<TODAY(),XLOOKUP(A9,$C9:$K9,$C$7:$K$7,,0)=TODAY()),XLOOKUP(A9,$C9:$K9,$C$7:$K$7,,0),""),"")
A10A10=IFNA(LOOKUP(2,1/((C10:CM10<>"")*(C10:CM10<>"Y")*(CM$11:PM$11<=TODAY())),C10:CM10),"")
A11A11=IFNA(LOOKUP(2,1/((C11:CM11<>"")*(C11:CM11<>"Y")*(OR(CM$11:PM$11<=TODAY(),CM$11:PM$11=TODAY()))),C11:CM11),"")
A12A12=IFNA(IF(B12>"",LOOKUP(2,1/((C12:K12<>"")*(C12:K12<>"Y")),C12:K12),""),"")
A13:A18A13=IFNA(LOOKUP(2,1/((C13:CM13<>"")*(C13:CM13<>"Y")),C13:CM13),"")

That's fine, it's a real date.
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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