Return largest value from other variable

Darkrun

New Member
Joined
Jul 31, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I've been having an issue trying to automate this sheet. I am trying to have it so that as I change the 'date to check' the Area in column C will update to the N column which has the highest date in column M, either before or equal to the new date in G1, if the Property code isn't in the L:N, to then return D:D. Column B will also show the date that is either the equal to or the highest under the G1 date.


1722417582688.png


I hope this makes sense and any help would be greatly appreciated.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Would this work?:

I didn't quite understand what you want to show if the code isn't found. In C2 show content of D2? And in B2 show the date in G1?

Book5.xlsx
ABCDEFGHIJKLMN
1Property codeDateAreaOriginal AreaDate to check05/03/2023Property codeDate of changeArea
27145377code not foundcode not found11267145377806/05/20231345
37145377801/06/20232346
47145377804/03/20244645
REturn largest value
Cell Formulas
RangeFormula
B2B2=LET( pc,$L$2:$L$1000, d,$M$2:$N$1000, fd,FILTER(d,pc=$A$2), IFERROR(XLOOKUP($G$1,CHOOSECOLS(fd,1),CHOOSECOLS(fd,1),"date not found",1), "code not found") )
C2C2=LET( pc,$L$2:$L$1000, d,$M$2:$N$1000, fd,FILTER(d,pc=$A$2), IFERROR(XLOOKUP($G$1,CHOOSECOLS(fd, 1),CHOOSECOLS(fd, 2),"date not found", 1), "code not found") )
 
Upvote 0
@felixstraube That doesn't seem to check if the result is less than or equal to the date in G3

Book2
ABCDEFGHIJKLMN
1Property codeDateAreaOriginal AreaDate to check3/5/2023Property codeDate of changeArea
2714537785/6/202313451126714537785/6/20231345
3714537786/1/20232346
4714537783/4/20244645
Sheet1
Cell Formulas
RangeFormula
B2B2=LET( pc,$L$2:$L$1000, d,$M$2:$N$1000, fd,FILTER(d,pc=$A$2), IFERROR(XLOOKUP($G$1,CHOOSECOLS(fd,1),CHOOSECOLS(fd,1),"date not found",1), "code not found") )
C2C2=LET( pc,$L$2:$L$1000, d,$M$2:$N$1000, fd,FILTER(d,pc=$A$2), IFERROR(XLOOKUP($G$1,CHOOSECOLS(fd, 1),CHOOSECOLS(fd, 2),"date not found", 1), "code not found") )
 
Upvote 0
How about:

Book2
ABCDEFGHIJKLMN
1Property codeDateAreaOriginal AreaDate to check3/5/2023Property codeDate of changeArea
2714537783/4/202323461126714537803/5/20231345
3714537783/4/20232346
4714537782/19/20234645
5
Sheet1
Cell Formulas
RangeFormula
B2:C2B2=IFERROR(LET(a,FILTER($L$2:$N$4,($M$2:$M$4<=$G$1)*($L$2:$L$4=A2)),DROP(FILTER(a,INDEX(a,,2)=MAX(INDEX(a,,2))),,1)),"not found")
Dynamic array formulas.
 
Last edited:
Upvote 0
@felixstraube That doesn't seem to check if the result is less than or equal to the date in G3
Yes, you are right. I had it wrong.
I think now it works as OP asked.

Book5.xlsx
ABCDEFGHIJKLMN
1Property codeDateAreaOriginal AreaDate to check01/06/2023Property codeDate of changeArea
27145377801/06/2023234611267145377806/05/20231345
37145377801/06/20232346
47145377804/03/20244645
REturn largest value
Cell Formulas
RangeFormula
B2:C2B2=LET( pc,$L$2:$L$1000, d,$M$2:$N$1000, fd,FILTER(d,pc=$A$2), IFERROR(XLOOKUP($G$1,CHOOSECOLS(fd,1),fd,"date not found",-1), "code not found") )
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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