Bringing back highest value with formula

adammon

New Member
Joined
Apr 8, 2015
Messages
14
I'm trying to set up a vlookup formula, or any kind of formula, that works for bringing back the highest value from a data set, as well as the corresponding cell adjacent to the highest value. To give full context, I'm trying to create a sheet for our warehouse to use as a replenishment tool. The logic is: scan in a product SKU, have the file look up against an overstock inventory listing, provide the user with the overstock location and the quantity for that location. The quantity needs to be the highest quantity in the data set and the location needs to be the corresponding location for that value.

Here is the starting point. Right now I just have a basic vlookup against the second data set. As it sits now, it's already bringing back the correct information, but that's only because the highest value is at the top of the list. So I need to make sure that I bring back the highest value in column D, and the pallet location with the highest value in column C.

Any help would be greatly appreciated.
Book1
ABCD
1SKUQTY NeededUPSTOCK PalletPallet QTY
203125-WANAV-L53A3F217
303125-WANAV-M22B2G23
403125-WANAV-XL53A3F22
Sheet1
Cell Formulas
RangeFormula
C2:C4C2=VLOOKUP(A2,Sheet2!$A$1:$C$11,2,FALSE)
D2:D4D2=VLOOKUP(A2,Sheet2!$A$1:$C$11,3,FALSE)


Book1
ABC
1SKUOverstock PalletQuantity
203125-WANAV-L3A3F217
303125-WANAV-L3A3G17
403125-WANAV-L2B2G21
503125-WANAV-M2B2G23
603125-WANAV-M3A9G23
703125-WANAV-M1B1F21
803125-WANAV-XL3A3F22
903125-WANAV-XL3A3G118
1003125-WANAV-XL1B1F22
1103125-WANAV-XS4B10G110
Sheet2
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this.
The formula in C2 is an arrary formula. Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself.

Book1
ABCD
1SKUQTY NeededUPSTOCK PalletPallet QTY
203125-WANAV-L53A3F217
303125-WANAV-M22B2G23
403125-WANAV-XL53A3G118
Sheet1
Cell Formulas
RangeFormula
C2:C4C2{=INDEX(Sheet2!$B$2:$B$11,MATCH(A2&"|"&D2,Sheet2!$A$2:$A$11&"|"&Sheet2!$C$2:$C$11,0))}
D2:D4D2=SUMPRODUCT(MAX((Sheet2!$A$2:$A$11=A2)*(Sheet2!$C$2:$C$11)))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.


_____________________________________________
You can also use this "regular" formula in C2

=INDEX(Sheet2!$B$2:$B$11,SUMPRODUCT(MAX((Sheet2!$A$2:$A$11=A2)*(Sheet2!$C$2:$C$11=D2)*ROW(Sheet2!$B$2:$B$11)))-1)
 
Upvote 0
Depending on your version of Excel, here are a couple of other options for finding the Pallet Qty and also another non array-entered formula for the UPSTOCK Pallet.

Book1
ABCDE
1SKUQTY NeededUPSTOCK PalletPallet QTYPallet QTY
203125-WANAV-L53A3F21717
303125-WANAV-M22B2G233
403125-WANAV-XL53A3G11818
Sheet1
Cell Formulas
RangeFormula
C2:C4C2=INDEX(Sheet2!$B:$B,AGGREGATE(15,6,ROW(Sheet2!A$2:A$11)/((Sheet2!A$2:A$11=A2)*(Sheet2!C$2:C$11=D2)),1))
D2:D4D2=MAXIFS(Sheet2!C$2:C$11,Sheet2!A$2:A$11,A2)
E2:E4E2=AGGREGATE(14,6,Sheet2!C$2:C$11/(Sheet2!A$2:A$11=A2),1)




You can also use this "regular" formula in C2

=INDEX(Sheet2!$B$2:$B$11,SUMPRODUCT(MAX((Sheet2!$A$2:$A$11=A2)*(Sheet2!$C$2:$C$11=D2)*ROW(Sheet2!$B$2:$B$11)))-1)
Just a comment on this one Dante. If somebody subsequently iserts any new row(s) at the top of Sheet2 this formula would return incorrect values.
You could turn your existing array-entered formula into a non array-entered one and avoid the potential row insertion problem as follows.

=INDEX(Sheet2!$B$2:$B$11,MATCH(A2&"|"&D2,INDEX(Sheet2!$A$2:$A$11&"|"&Sheet2!$C$2:$C$11,0),0))
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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