Is it possible to access the grouping level in an Excel formula

I have an Excel sheet that looks something like this:

enter image description here

Is it possible to write a formula which accesses the grouping levels (the numbers marked in red)?

The problem is that we have a piece of software which exports a BOM (Bill Of Materials) describing, in a top-down manner, the different articles contained in mechanical product. The grouping number is the only way to know which level a certain article is on.


Solution 1:

why not try VBA script of macro?

I think this will help: Worksheets("Sheet1").Rows(i).OutlineLevel

Go through the sheet and write this property into cells.