Sum values based on indent

jocker_boy

Board Regular
Joined
Feb 5, 2015
Messages
83
Hi,

I want to sum values based on indent level in another column. Example:

text
A
0
9
A.1
2
2
A.2
4
4
A.3
5
5
B
0
3
B.1
1
1
B.2
2
2
C
0
5
C.1
3
3
C.2
2
2

<tbody>
</tbody>

I have my different strings in column A:A
And in column B:B i have a formula to find the string in column A in one text cell (Row 1:1).
But i want to organize by "headers"
The goal is obtain column C:C automatically, because i have several tables and they are not equal.

I was thinking in somethig like:

In cell B2: if indent of A2=0, sum cell B3:BXX, until the next indent of column A=0.

Does this make any sense?

I have already a VBA code to get the indent:
Code:
Function PROFEXIndentLevel(Cell As Range)
    'This function returns the indentation of a cell content
    
    Application.Volatile
    'With "Application.Volatile" you can make sure, that the function will be recalculated once the worksheet is recalculated
    'for example, when you press F9 (Windows) or press enter in a cell
    
    PROFEXIndentLevel = Cell.IndentLevel
    'Return the IndentLevel
    
End Function

Thanks,
Gonçalo
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
What if you just use the below formula instead?

Code:
=IF(LEN(A2)=1,SUMPRODUCT(--(LEFT($A$2:$A$11,1)=LEFT($A2,1)),$B$2:$B$11),B2)
 
Upvote 0

Forum statistics

Threads
1,215,262
Messages
6,123,938
Members
449,134
Latest member
NickWBA

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