Custom Sorting

theraindew

New Member
Joined
Dec 7, 2018
Messages
9
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi,

I'm looking to sort columns in a specific way in the attached image.

Columns A & B - original data.
Columns D & E - sorted data.

Primary sort should be column B (Total), but duplicate fruit names should be clubbed together, regardless of the value of the duplicate fruit name.

Can this be done using a formula/helper column or even vba? Appreciate any help on this.
 

Attachments

  • sort.JPG
    sort.JPG
    27.5 KB · Views: 19

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try adding a helper column as below, sort by helper, then total, then fruit.
Book2
ABC
1fruittotalhelper
2apple100100
3apricot9090
4strawberry7979
5strawberry5579
6blueberry6363
7cherry6060
8cherry4560
9cranberry5050
Sheet4
Cell Formulas
RangeFormula
C2:C9C2=MAXIFS($B$2:$B$9,$A$2:$A$9,A2)
 
Upvote 0
For your version of Excel, I think you would need something like this in your helper column & then sort as suggested by jasonb75 or, depending on what you want if two different fruits have an equal max total, you may want to sort by helper, then fruit, then total.

20 05 30.xlsm
ABC
1fruittotalhelper
2apple100100
3apricot9090
4strawberry7979
5blueberry6363
6cherry4560
7cranberry5050
8strawberry5579
9cherry6060
Sort Special
Cell Formulas
RangeFormula
C2:C9C2=AGGREGATE(14,6,B$2:B$9/(A$2:A$9=A2),1)
 
Last edited:
Upvote 0
Thanks, Peter!

Not sure if OP has just updated their profile, but didn't notice 2016 their earlier.
 
Upvote 0
Thank you jasonb75 and Peter_SSs. Yes i did not mention my office version earlier. Updated it after reading "Formulas provided for Excel 2019 unless your profile shows an older version." :p I was able to look up the Aggregate formula after looking at jasonb75's reply. The formula and three way sorting works great! Thanks again both for the quick help.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,432
Members
448,961
Latest member
nzskater

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