Excel: Subtotal and Hierarchy Template and Macro

If you have an Outline numbered list and values against each entry, it should be easy to add things up in a hierarchical manner so you can figure out how much each level costs easily.

Excel does have a nice "subtotal" formula, but it requires you to manually specify the range to add.

Excel also offers a "SUBTOTAL" button that more or less automates this based on the grouping level. But the "SUBTOTAL" button has the following problems:

Basically this button is only useful if you have a dump from a database without any existing headings or breaks.

So I have written a template with included macros and a ribbon that adds subtotals based on only the numerical outline levels.

It also features outline grouping, and colouring of heading levels.

Each level is indicated by the indenting of the row, using three spaces per indent.

Hierarchical Pivot Table

In addition, the template will also produce a fully hierarchical pivot table to validate all the subtotal figures, and provide rollups if you want to hide subvalues. It uses the H1 ~ H4 columns to do this automatically.

Ribbon

A new ribbon entry called "Hierarchy" appears when you open up the Excel file. This allows you to insert new rows, move and indent tasks, update the formatting, and update subtotals.

NOTE: If you'd like to contribute, to add new buttons, please see the tutorial here: https://stackoverflow.com/questions/8850836/how-to-add-a-custom-ribbon-tab-using-vba

The GUI "Office Custom UI Editor" can be found here: https://github.com/OfficeDev/office-custom-ui-editor/tree/master/publish or here: https://github.com/OfficeDev/office-custom-ui-editor/issues/3

Summary Columns

The Update Subtotals button also checks for any text summary columns, designated with ";;". 

This allows text summaries like the following:

NOTE: If you need to allocate multiple resources to a line manually, please use ";" or ",", not a double ";;". The formula will replace any lines with ";;" with a formula. This may result in some duplicate values, however this is the only way to make the formula work in Office 2019. In Office 2021 and above, the "unique" and "textsplit" formulas can be used to eliminate these duplicates, however for backward compatibility I haven't used them.

Notes

TODO

INSTALLATION