Find Maximum Value in Column Without Using Array or CTRL+SHFT+ENTER?

zgadson

Board Regular
Joined
Jul 16, 2015
Messages
68
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,

Per the attached screenshot, I've got a spreadsheet that lists warehouse locations and the name of the item in each location. The sheet also has a column that says how many pallets high each item is stacked. There are 500+ different items, and a lot of them repeat because they are in multiple locations in my warehouse, so formulas with an array or that use CTRL+SHIFT+ENTER would take way too long to process. Is there an alternative way to search this whole sheet to get the maximum value for each item without using an array formula?

Thanks,
Zach
 

Attachments

  • Screenshot.PNG
    Screenshot.PNG
    27.7 KB · Views: 16

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You can use MAXIFS if you have excel 2019 or office 365, other than that you will need an array formula.

The other option would be a pivot table.
 
Upvote 0
Hi ZGadson,

Assuming you don't have a list of each item I've created that in column F. Column G then gives you the maximum pallet height for that product.

ZGadson.xlsx
ABCDEFG
1ItemPallet HeightDistinct ListMax Pallet Height
2Hydrogen Peroxide Cleaner (50 gallon)2Hydrogen Peroxide Cleaner (50 gallon)5
3Ammonia (clear, 5 gallon)2Ammonia (clear, 5 gallon)6
4Disinfectant (55 gallon drum)2Disinfectant (55 gallon drum)2
5Drain Treatment 25 gallon)2Drain Treatment 25 gallon)9
6Liquid Bleach (25 gallon)2Liquid Bleach (25 gallon)12
7Liquid Laundry Detergent (25 gallon)2Liquid Laundry Detergent (25 gallon)44
8Hydrogen Peroxide Cleaner (50 gallon)5  
9Ammonia (clear, 5 gallon)6  
10Disinfectant (55 gallon drum)1  
11Drain Treatment 25 gallon)9  
12Liquid Bleach (25 gallon)12  
13Liquid Laundry Detergent (25 gallon)44  
14
Sheet1
Cell Formulas
RangeFormula
F2:F13F2=INDEX($A$2:$A$999,MATCH(0,INDEX(COUNTIF($F$1:$F1,$A$2:$A$999),),0))&""
G2:G13G2=IF(F2="","",AGGREGATE(14,6,$B$2:$B$999/($A$2:$A$999=F2),1))
 
Upvote 0
@Toadstool the OP asked for formulas that don't use arrays.

INDEX(COUNTIF($F$1:$F1,$A$2:$A$999),) is an array.

$B$2:$B$999/($A$2:$A$999=F2) is an array.

Personally, I would use a pivot instead of formulas. Using Item descriptions for pivot rows and Pallet height for pivot values, value field set to max of.
 
Upvote 0
Use Excel's built-in Pivot Table feature (on the Insert ribbon tab)?

Edit: :oops: Ooops, missed that jasonb75 already suggested this (twice!!). :oops:

20 07 14.xlsm
ABCDEF
1ItemPallet HeightRow LabelsMax of Pallet Height
2Hydrogen Peroxide Cleaner (50 gallon)2Ammonia (clear, 5 gallon)6
3Ammonia (clear, 5 gallon)2Disinfectant (55 gallon drum)2
4Disinfectant (55 gallon drum)2Drain Treatment 25 gallon)9
5Drain Treatment 25 gallon)2Hydrogen Peroxide Cleaner (50 gallon)5
6Liquid Bleach (25 gallon)2Liquid Bleach (25 gallon)12
7Liquid Laundry Detergent (25 gallon)2Liquid Laundry Detergent (25 gallon)44
8Hydrogen Peroxide Cleaner (50 gallon)5Grand Total44
9Ammonia (clear, 5 gallon)6
10Disinfectant (55 gallon drum)1
11Drain Treatment 25 gallon)9
12Liquid Bleach (25 gallon)12
13Liquid Laundry Detergent (25 gallon)44
Max



I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data (or use Toadstool's) to test with.
 
Last edited:
Upvote 0
I'd assumed the OP had omitted the commas of a non-essential clause so "or that use CTRL+SHIFT+ENTER" was further explanation of "formulas with an array".
Looking at the rest of that line from the OP,
so formulas with an array or that use CTRL+SHIFT+ENTER would take way too long to process.
Maybe my logic is flawed, but in my opinion an array is going to take equal time to process with or without CSE, possibly using INDEX to circumvent CSE confirmation might even make it a billionth of a second slower as it is an extra function to process ;)
 
Upvote 0
Another way that should be pretty fast

VBA Code:
Sub Max_Values()
  Dim d As Object
  Dim a As Variant
  Dim i As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  a = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value
  For i = 1 To UBound(a)
    If a(i, 2) > d(a(i, 1)) Then d(a(i, 1)) = a(i, 2)
  Next i
  With Range("E2:F2").Resize(d.Count)
    .Value = Application.Transpose(Array(d.Keys, d.Items))
    .Rows(0).Value = Array("Item", "Max Height")
    .EntireColumn.AutoFit
  End With
End Sub
 
Upvote 0
Thanks so much guys! I think Toadstool's pivot table idea is the best way, however, I need your column F to be in the main data listed in the next column. (In your example, column B has the original heights, so I'd need column C to be the maximum height (even if the item is repeated, I still need the max height next to it.)

Thanks!
Zach
 
Last edited by a moderator:
Upvote 0
Hi ZGadson,

The pivot table solution was proposed by JasonB75 and Peter_SSs. My solution uses functions.

If you need the max in column C and it doesn't matter if it's repeated then my sheet would look like this:

ZGadson.xlsx
ABC
1ItemPallet HeightMax
2Hydrogen Peroxide Cleaner (50 gallon)25
3Ammonia (clear, 5 gallon)26
4Disinfectant (55 gallon drum)22
5Drain Treatment 25 gallon)29
6Liquid Bleach (25 gallon)212
7Liquid Laundry Detergent (25 gallon)244
8Hydrogen Peroxide Cleaner (50 gallon)55
9Ammonia (clear, 5 gallon)66
10Disinfectant (55 gallon drum)12
11Drain Treatment 25 gallon)99
12Liquid Bleach (25 gallon)1212
13Liquid Laundry Detergent (25 gallon)4444
14 
15 
2ndexample
Cell Formulas
RangeFormula
C2:C15C2=IF(A2="","",AGGREGATE(14,6,$B$2:$B$999/($A$2:$A$999=A2),1))
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,860
Members
449,194
Latest member
HellScout

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