VLOOKUP which gives highest value

cpisthedbb

New Member
Joined
Apr 10, 2018
Messages
30
Hi,

The spreadsheet I am using has 3 orders which make one bulk order. The 3 orders have 3 different finish dates. Is there a way of putting on a vlookup formula which then chooses the highest date (this is to create a pivot table).

For example:

Order Finish date Bulk order
1 01/01/18 500
2 05/01/18 500
3 06/01/18 500

So in this example I need to look up the last finish date for Bulk order 500 which is 06/01/18 and ignore the 01/01 & 05/01.

Hope this makes sense.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If you have the MAXIFS function (Office 365) you can use F2
If you have Excel 2010 or later you can use G2
H2 for all versions but this is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

Excel Workbook
ABCDEFGH
1Order Finish dateBulk orderBulk orderLast date
221/01/20184005006/01/20186/01/20186/01/2018
32/01/201840040021/01/201821/01/201821/01/2018
41/01/2018500
55/01/2018500
66/01/2018500
Highest date
 
Upvote 0
If you have the MAXIFS function (Office 365) you can use F2
If you have Excel 2010 or later you can use G2
H2 for all versions but this is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

Highest date

ABCDEFGH

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:121px;"><col style="width:78px;"><col style="width:25px;"><col style="width:21px;"><col style="width:74px;"><col style="width:103px;"><col style="width:97px;"><col style="width:97px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: right"]Order Finish date[/TD]
[TD="align: right"]Bulk order[/TD]

[TD="align: right"]Bulk order[/TD]
[TD="align: right"]Last date[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]
[TD="align: right"]21/01/2018[/TD]
[TD="align: right"]400[/TD]

[TD="align: right"]500[/TD]
[TD="align: right"]6/01/2018[/TD]
[TD="align: right"]6/01/2018[/TD]
[TD="align: right"]6/01/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]
[TD="align: right"]2/01/2018[/TD]
[TD="align: right"]400[/TD]

[TD="align: right"]400[/TD]
[TD="align: right"]21/01/2018[/TD]
[TD="align: right"]21/01/2018[/TD]
[TD="align: right"]21/01/2018[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]
[TD="align: right"]1/01/2018[/TD]
[TD="align: right"]500[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]
[TD="align: right"]5/01/2018[/TD]
[TD="align: right"]500[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]
[TD="align: right"]6/01/2018[/TD]
[TD="align: right"]500[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
F2=MAXIFS(A$2:A$6,B$2:B$6,E2)
G2=AGGREGATE(14,6,A$2:A$6/(B$2:B$6=E2),1)
H2{=MAX(IF(B$2:B$6=E2,A$2:A$6))}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


Thanks for the quick reply. I'm using 2010 Excel- for some reason G2 formula isn't giving me the dates and H2 I'm getting the #NUM ! error. I must be doing something wrong but I'm not sure what...
 
Upvote 0
G2 formula isn't giving me the dates ..
What is G2 giving you?


Do you have any existing errors (eg #NUM !) in columns A:B?

If you try the G2 & H2 formulas in a new sheet with the sample data I used manually entered, do they work for you?

BTW, best not to fully quote long posts as it makes the thread harder to read/navigate. If you want to quote, quote small, relevant parts only.
 
Last edited:
Upvote 0
What is G2 giving you?


Do you have any existing errors (eg #NUM !) in columns A:B?

If you try the G2 & H2 formulas in a new sheet with the sample data I used manually entered, do they work for you?
.

What is G2 giving you?


Do you have any existing errors (eg #NUM !) in columns A:B?

If you try the G2 & H2 formulas in a new sheet with the sample data I used manually entered, do they work for you?

Thanks for the reply. G2 gives the date 00/01/00. The columns a:b do have some n/a values in as it works off a VLOOKUP. Is this likely the issue?

The formula did work when I copied and pasted your table so is my spreadsheet.
 
Upvote 0
G2 gives the date 00/01/00.
That would seem to indicate that the only rows for that Bulk order number have zero or blank cells in column A. Example below. Is that the case?

Excel Workbook
ABCDEG
1Order Finish dateBulk orderBulk orderLast date
221/01/20184005000/01/1900
3N/A40040021/01/2018
4500
5N/A500
6500
Highest date




The columns a:b do have some n/a values in as it works off a VLOOKUP. Is this likely the issue?
Yes it is, I suggest that you change those column A VLOOKUP formulas as follows & see how that goes.

=IFERROR(your_existing_vlookup,"N/A")
 
Upvote 0
Hi Peter,

Late reply but I've only just got around to re-looking at this. I managed to get this to work so thanks for your help, once again you've come up trumps!
 
Upvote 0
You’re welcome. Glad you were able to resolve the final issues.
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,991
Members
452,541
Latest member
haasro02

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