VBA custom sort by category total

mbk1623

New Member
Joined
Mar 29, 2016
Messages
1
Tried my best to figure out the best way to do this and came up short.

My data looks something like this:

Category 1Category 2Account DescFY13FY14FY15
Revenue
Product 1
Sales100110115
RevenueProduct 3Sales100150300
Cost of RevenueProduct 1COGS203030
Cost of RevenueProduct 2COGS202020
Cost of RevenueProduct 2Returns564
RevenueProduct 1Returns-20-30-50
RevenueProduct 2 Sales90900
Cost of RevenueProduct 3COGS589
Cost of RevenueProduct 3Reserves101010

<tbody>
</tbody>


I'll be sorting the "Category1" column based on a customer sort order, which I will perform using CustomOrder: within the sort function, but the part I' stuck on is I'd also like to be able to sort within each unique field in "Category 1" in descending order based on the totals found in the columns "FY13", "FY14", and FY15", (where the fields are sorted by each Fiscal Year in that order since there will often be cases where some data might have null values in some Fiscal Years.)

For example, "Revenue, Product 1, Sales" is the second highest value in FY15 for Revenue, but when combined with "Revenue, Product 1, Returns", Product 1 is now the lowest amount among the 3 products. As such, i want all Product 1 values to appear last within the Revenue group. I want Cost of Sales to have the same logic independently applied.

I will also be sorting "Account Description" from highest to low within each grouping, but since this is my most granular field, I can just sort in descending order for each Fiscal Year before doing any of the above.

This is a simplified example, but I will be looping through many more fields than listed here, which will always change depending on the data.

Appreciate any help!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,217,360
Messages
6,136,102
Members
449,991
Latest member
IslandofBDA

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