How to Group Excel WBS Rows Automatically by Outline Level
Question details
The user needs to group rows into nested outlines based on their Work Breakdown Structure (WBS) levels in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Organizing a project hierarchy by applying Outline Grouping based on the WBS identifier values.
- Observed behavior
- While it is possible to count WBS levels using a formula, filtering and grouping visible rows fails to create proper nested outlines, meaning manual grouping or VBA automation is required.
Ensure your WBS identifiers are formatted consistently (e.g., 1.1, 1.1.2) in a single column, as the grouping logic relies on the exact number of delimiters (dots) in the ID.
Calculate WBS Levels Using a Helper Formula
Use a text-manipulation formula to determine the hierarchy level of each row based on the number of dots in its WBS ID.
Before you can automate or manually group the rows properly, you need to determine the hierarchy level of each task. Excel can calculate the depth of a WBS identifier by counting how many dots (.) it contains.
Insert a new column next to your WBS ID column and name it 'WBS Level'.
Assuming your first WBS ID is in cell A2, type the formula =LEN(A2)-LEN(SUBSTITUTE(A2,".","")) into the helper column.
Drag the fill handle down to apply this formula to all rows in your project list. The result will represent the outline level.

Automate Nested Row Grouping with VBA
Since Excel cannot automatically nest groups via filtering, use a VBA macro to read the calculated levels and apply Outline Grouping.
Manually Group Rows Using the Outline Feature
For smaller datasets where VBA is unnecessary, use Excel's built-in Data Grouping tool to manually create nested rows.
Easily Manage Project Data and Grouping with WPS Spreadsheet
WPS Spreadsheet offers powerful data management tools, full compatibility with Excel VBA macros, and intuitive row grouping capabilities to help you organize your WBS structures effortlessly.
- 1. Open your Project File: Launch WPS Spreadsheet and open your WBS document.
- 2. Calculate Levels: Use the same LEN and SUBSTITUTE formulas to count WBS levels natively.
- 3. Apply Grouping or Macros: Use the 'Group' tool under the Data tab, or run your existing VBA macro using the built-in VBA editor.

Frequently Asked Questions
Can I use Excel's Subtotal feature to group WBS rows automatically?
While the Subtotal feature can automatically group data, it works best for aggregating values based on distinct category changes, rather than building complex nested project hierarchies strictly from WBS IDs.
Why doesn't filtering and grouping visible rows work properly?
Excel's grouping feature applies to consecutive row numbers in the spreadsheet. If you filter rows and apply a group, Excel will often group the hidden rows between them as well, breaking the intended nested outline structure.
How do I clear all existing outline groups in my spreadsheet?
Go to the Data tab, click the arrow below 'Ungroup' in the Outline section, and select 'Clear Outline' to remove all row and column groups from the active worksheet.
Will WPS Office run my Excel VBA macro for WBS grouping?
Yes, WPS Office offers comprehensive VBA support. You can open your .xlsm file in WPS Spreadsheet and run your existing WBS grouping macros without needing to modify the code.




