Macro to Sort and Label Metrics

DJL_DASH

New Member
Joined
Jul 8, 2011
Messages
16
Hello!
Essentially, I want to create a macro that automatically sorts and re-labels a list of metrics each time a change is made, whether that be inserting a row, or changing one of the metrics labels. Each individual metric is listed a different row, and it is defined by labels listed in the first row of the worksheet. Each of the labels describe a single column (see attached)

E-mail me
here if you want to know what the metrics look like before this macro runs, and what the metrics should look like after.

Here are the following labels, and the conditions I want to impart to them:

Sort by: Priority - Order: Smallest to Largest
Then by: Category - Order A to Z
Then by: Sub - Category Order: A to Z
Then by: Metric Order: A to Z
Then by: Sub - Metric Order: A to Z


**For the sake of ease I refer to the metrics as rows

Now, you may be thinking to yourself, "This is easy! You can just use the sort command in Excel!" HOWEVER, it gets more complicated...

If 2 (+) rows of have the same 'Metric' Label, they should automatically be grouped together, no matter what the other labels and their sort priorities are. This group should be sorted according the the conditions above, and then be treated as a single metric to sort relative to the rest of the list. Also if a sub-metric in a group is labeled either "Total" or "Other", it should automatically be placed as the bottom most row of the group (not the entire list).

After the sorting takes place, the metric should take a look at the left most column labeled "ID", and label each of the metrics with a prefix and a number (ie: "ID-3") in ascending order. HOWEVER, if the each of the row has the same "METRIC" label, it should name each one in that group "ID-3A, ID-3B, etc."


Alright this pretty much sums up what I want to do. I am not too experienced with VBA, so I appreciate your feedback/ any code to help me get started...

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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