Order array by value using formula

ddoublev2010

New Member
Joined
May 16, 2020
Messages
3
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,

Im trying to set up some dynamic sorted ranges.
The top section are array formulas searching a large table of data for records that match given criteria. This part is working fine
The bottom section is supposed to sort the names by value largest to smallest.
As shown on the left it works as long as the range it is searching includes data in all cells
On the right it returns an error, have tested by reducing the range to only cells with data and it works perfectly.

1589636489887.png


The formula in P22 is:
=INDEX($P$16:$P$20,MATCH(LARGE($Q$16:$Q$20+ROW($Q$16:$Q$20)/1000,O22),$Q$16:$Q$20+ROW($Q$16:$Q$20)/1000,0))

Any ideas how I can do this with ability to ignore blanks/errors?

All assistance is appreciated
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
When you reentered the formula, did you confirm with Ctrl-Shift-Enter? I didn't get the same error that you describe.
 
Upvote 0
for your reference.
if you need descending order, change the last 1 to -1.
新建Microsoft Excel 工作表.xlsx
STU
15HelmValue
161A0.616665
172B0.478017
183C0.096805
194D0.202108
205
21
221C
232D
243B
254A
265
Sheet1
Cell Formulas
RangeFormula
T22:T26T22=INDEX(SORT(T16:U20,2,1),,1)&""
Dynamic array formulas.
 
Upvote 0
I agree with @KRice that you shouldn't be getting the error if the formula is entered correctly (except for the last row where it will show the error because there is no match or function to catch the error).
@shaowu459 has provided an alternative method for you which will only work with up to date installations of office 365, I've added another one for you that will work with all versions from 2010 onwards.
Book1 (version 1).xlsb
OPQ
161Dornish0.30176
172Stark0.27522
183Stark Relics0.36736
194Whent0.30176
205
21
221Stark Relics0.36736
232Dornish0.30176
243Whent0.30176
254Stark0.27522
26   
Sheet1
Cell Formulas
RangeFormula
O22:O26O22=IF(ROWS(O$22:O22)>COUNT($Q$16:$Q$20),"",ROWS(O$22:O22))
P22:P26P22=IF(O22="","",INDEX($P:$P,AGGREGATE(15,6,ROW($P$16:$P$20)/($Q$16:$Q$20=Q22),COUNTIF(Q$22:Q22,Q22))))
Q22:Q26Q22=IF(O22="","",LARGE($Q$16:$Q$20,O22))
 
Upvote 0
Thankyou very much for your assistance, for some reason the array formulas were not working, the solution from Jason has worked perfectly
Thanks again
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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