Choose Max Date

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to get the maximum "End Date" for a WT & Step # combo. My "Lookup Field" is the left column and I am using the following formula to lookup the end date, but it only pulls the first record in the list, I want to get the maximum date from the list.

How can I modify this formula to give me that?

VBA Code:
VLOOKUP("000000021607-23",ScanHist[[LookupField2]:[End Date]],11,FALSE)


LookupField2WTNumberTransactionDateStartDateStartTimeStartStart DateEndDateEndEndTimeEnd Date
000000021607-1000000002160744792202208198.508/19/20228/19/22 8:30 AM2022081908/19/20228.758/19/22 8:45 AM
000000021607-20000000021607448052022090111.409/01/20229/1/22 11:24 AM2022090109/01/202215.49/1/22 3:24 PM
000000021607-23000000021607447922022081910.4333308/19/20228/19/22 10:26 AM2022081908/19/202210.533338/19/22 10:31 AM
000000021607-2300000002160744796202208237.1508/23/20228/23/22 7:09 AM2022082308/23/202215.066678/23/22 3:04 PM
000000021607-2300000002160744797202208247.1666708/24/20228/24/22 7:10 AM2022082408/24/202215.233338/24/22 3:13 PM
000000021607-2300000002160744798202208257.1508/25/20228/25/22 7:09 AM2022082508/25/202210.566678/25/22 10:34 AM
000000021607-2300000002160744805202209017.7333309/01/20229/1/22 7:44 AM2022090109/01/202212.133339/1/22 12:07 PM
000000021607-26000000021607448052022090111.4509/01/20229/1/22 11:27 AM2022090109/01/202215.459/1/22 3:27 PM
000000021607-4000000002160744816202209125.9666709/12/20229/12/22 5:58 AM2022091209/12/20226.466679/12/22 6:28 AM
000000021607-7000000002160744812202209085.909/08/20229/8/22 5:54 AM2022090809/08/2022139/8/22 1:00 PM
000000021607-7000000002160744816202209126.5666709/12/20229/12/22 6:34 AM2022091209/12/20226.566679/12/22 6:34 AM
000000021607-80000000021607448342022093014.4509/30/20229/30/22 2:27 PM2022093009/30/202214.79/30/22 2:42 PM
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Maybe
=MAX(IF(A2:A100="000000021607-23",C2:C100))

Be sure to commit that formula to the cell with Ctrl+Shift+Enter, not just with Enter.
Also, I see you used named ranges which I never use, so adjust my cell references accordingly if this formula (again, with Ctrl+Shift+Enter) works as you want.
 
Upvote 0
Maybe
=MAX(IF(A2:A100="000000021607-23",C2:C100))

Be sure to commit that formula to the cell with Ctrl+Shift+Enter, not just with Enter.
Also, I see you used named ranges which I never use, so adjust my cell references accordingly if this formula (again, with Ctrl+Shift+Enter) works as you want.
Hi tom,

This works great, if there is a record to find. I am finding that if 21607 exists anywhere with a step number (even if it is a different step number), it returns a value of 1/0/00 12:00 am. If 21607-23 does not exist, it should return a value of "". Can that be coded?

I tried: =MAX(IF(A2:A100="000000021607-23",C2:C100,"")) but that did not work.
 
Upvote 0
it returns a value of 1/0/00 12:00 am
That is just zero, formatted as a date.

Try something like this, using the MAXIFS function I suggested, which does NOT require you to use CNTRL+SHIFT+ENTER:
Excel Formula:
=LET(x,MAXIFS(C2:C13,A2:A13,"000000021607-23"),IF(x=0,"",x))
 
Upvote 0
Solution
Another option
Excel Formula:
=TAKE(SORT(FILTER(ScanHist[End Date],ScanHist[LookupField2]="000000021607-23",""),,-1),1)
 
Upvote 0
That is just zero, formatted as a date.

Try something like this, using the MAXIFS function I suggested, which does NOT require you to use CNTRL+SHIFT+ENTER:
Excel Formula:
=LET(x,MAXIFS(C2:C13,A2:A13,"000000021607-23"),IF(x=0,"",x))
This worked like a perfect dream! Thank you very much @Joe4 !
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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