sorting with duplicates and zero values

Tkeller

Board Regular
Joined
Jul 23, 2003
Messages
143
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have an array that will have 10 numbers in it. Within these numbers, there could be zero values as well as duplicate values. For example:

1) 0
2) 30
3) 50
4) 0
5) 20
6) 30
7) 20
8) 0
9)100
10) 90

I need to be able to sort these using a (array) formula in ascending order, including duplicate and zero values. For example, from above, the order would be:

1,4,8,5,7,2,6,3,10,9

I know about "rank", but this does not help me with the duplicates. Any help would be appreciated.

Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Tkeller,

Would you be willing to add some columns? you could just do a =Left(a2,find etc..) formula and do a simple sort?

Have '1) 0' as two hidden columns '1' & '0' then sort by '0' then '1'.

I don't think it needs to be complicated.

Hope this helps,
HappyMeal :)
 
Upvote 0
Happymeal.

Thanks. I think I could add some columns if it helped me to solve this. Please help my out though, as I am not sure I understand the solution. This would have to be a formula-driven automated solution - note that I am just giving an example above, the actual values will be different with each run of the model.
 
Upvote 0
If '1) 0' was in cell A2 you would use the following formulas

Code:
=LEFT(A2,FIND(")",A2&")")-1)
Code:
=RIGHT(A2,LEN(A2)-FIND(")",A2))

Then use your sort on the two columns with the formulas, this will sort the data the way you want it.

Hope this helps,
HappyMeal :)
 
Upvote 0
Assuming your data starts in A1 enter below formula in B1 and drag it down:

Code:
=SMALL($A$1:$A$10,ROW(A1))

Sample workbook:

Code:
https://app.box.com/s/bhbkgw71aj8qkv54zzqo
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

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