Retrieve cells with highest sumif values

robert1012

New Member
Joined
Sep 26, 2024
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
I have a list of stocks in column B and the paid amount in column C ("Pay").
I want excel to generate a list of the 5 stocks with the highest total "pay" amount based on a formula (preferably not a pivot table).

I have tried to use a combination of SUMIF & LARGE, but it's just not working.
In cells F2:G6 is the result I should obtain by using a formula.
Can anyone tell me if there's a formula I can use to get this result?
 

Attachments

  • stocks.JPG
    stocks.JPG
    96.9 KB · Views: 9

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Could You paste this as sheet (use XL2bb addin, if You do not know how)?
 
Upvote 0
Could You paste this as sheet (use XL2bb addin, if You do not know how)?
Not sure how this works, I tried to follow the steps in the description by copying the "Mini Sheet" from excel:

Generate Largest Sumif values.xlsx
G
12
Sheet1
 
Upvote 0
Generate Largest Sumif values.xlsx
ABCDEFG
1#StockPayTopStockPay
21BAC$ 100.01BAC$ 1,099.4
32GLD$ 56.72WFC$ 272.0
43WFC$ 56.33FB$ 225.1
54WU$ 43.74MA$ 225.1
65VXX$ 59.25JPM$ 197.5
76CROX$ 47.7
87XLF$ 44.8TopStockPay
98Book$ 49.01
109C$ 58.02
1110GS$ 43.63
1211Book$ 53.84
1312BRK$ 75.75
1413JPM$ 52.9
1514FB$ 75.2
1615BAC$ 68.2
1716GLD$ 65.6
1817ING$ 47.9
1918DB$ 54.1
2019XXX$ 39.7
2120BTC$ 38.7
2221GOOGL$ 88.2
2322LUK$ 75.9
2423WFC$ 80.5
2524BAC$ 84.2
2625BAC$ 57.4
2726BRK$ 117.6
2827GOOGL$ 75.4
2928FB$ 79.9
3029BAC$ 107.7
3130AAPL$ 83.7
3231FB$ 70.0
3332C$ 71.9
3433BAC$ 63.8
3534AAPL$ 80.2
3635BAC$ 65.6
3736V$ 55.7
3837MA$ 55.0
3938BAC$ 54.5
4039AXP$ 54.9
4140MA$ 56.4
4241MA$ 53.7
4342BAC$ 95.5
4443BUD$ 70.7
4544SPY$ 98.9
4645BAC$ 126.0
4746BTC$ 59.3
4847SPY$ 47.8
4948QQQ$ 54.8
5049V$ 95.1
5150BAC$ 113.7
5251MA$ 60.1
5352WFC$ 135.3
5453JPM$ 82.1
5554BAC$ 77.6
5655JPM$ 62.5
5756BAC$ 85.2
5857SPY$ 35.1
5958UMIC$ 84.0
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G2:H6Cell Value=""textNO
G2:H6Expression=$F2<4textNO
G2:H6Expression=AND($F2<10,$F2>3)textNO
 
Upvote 0
Hi! This should work.
Book1.xlsm
ABCDEFG
1#StockPayTopStockPay
21BAC100,031WFC135,26
32GLD56,672BAC126,00
43WFC56,283BRK117,55
54WU43,704BAC113,74
65VXX59,205BAC107,74
76CROX47,67
87XLF44,80
98Book48,95
109C57,96
1110GS43,62
1211Book53,80
1312BRK75,74
1413JPM52,91
1514FB75,22
1615BAC68,22
1716GLD65,56
1817ING47,93
1918DB54,06
2019XXX39,74
2120BTC38,73
2221GOOGL88,23
2322LUK75,86
2423WFC80,46
2524BAC84,18
2625BAC57,41
2726BRK117,55
2827GOOGL75,39
2928FB79,92
3029BAC107,74
3130AAPL83,68
3231FB69,98
3332C71,93
3433BAC63,80
3534AAPL80,16
3635BAC65,59
3736V55,67
3837MA54,96
3938BAC54,46
4039AXP54,89
4140MA56,36
4241MA53,65
4342BAC95,50
4443BUD70,72
4544SPY98,88
4645BAC126,00
4746BTC59,34
4847SPY47,79
4948QQQ54,80
5049V95,08
5150BAC113,74
5251MA60,14
5352WFC135,26
5453JPM82,08
5554BAC77,55
5655JPM62,50
5756BAC85,18
5857SPY35,11
5958UMIC84,01
Sheet7
Cell Formulas
RangeFormula
F2:F6F2=INDEX($B$2:$B$59,MATCH(LARGE($C$2:$C$59,$E2),$C$2:$C$59,0))
G2:G6G2=LARGE($C$2:$C$59,$E2)
 
Upvote 0
Hmm for XL365 is possible to sort with 1 formula. For 2019 I've used 3 helpers columns (data as on original in columns A1:C59):

Cell Formulas
RangeFormula
F9F9=INDEX($F$16:$F$42,MATCH($E9,$H$16:$H$42,0))
G9:G13G9=INDEX($G$16:$G$42,MATCH($E9,$H$16:$H$42,0))
F10:F13F10=INDEX($F$16:$F$42,MATCH(E10,$H$16:$H$42,0))
J9:K13J9=LET(xNames,UNIQUE($B$2:$B$59),xValues,SUMIFS($C$2:$C$59,$B$2:$B$59,xNames),xResult,HSTACK(xNames,xValues),CHOOSEROWS(SORT(xResult,2,-1),ROW(1:5)))
F16:F42F16=IFERROR(INDEX($B$2:$B$59,MATCH(0,COUNTIF($F$15:F15,$B$2:$B$59),0)),"")
G16:G42G16=SUMIFS($C$2:$C$59,$B$2:$B$59,$F16)
H16:H42H16=RANK($G16,$G$16:$G$42)
Press CTRL+SHIFT+ENTER to enter array formulas.
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,222,902
Messages
6,168,938
Members
452,227
Latest member
sam1121

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