VBA subtotal depending on indent

jocker_boy

Board Regular
Joined
Feb 5, 2015
Messages
83
Hi,

I have a table with text and numbers that i got from MSProject, for example:


<tbody>
A
36
A.110
A.212
A.314
B
61
B.1
38
B.1.115
B.1.211
B.1.312
B.211
B.312

<colgroup><col span="2"></colgroup><tbody>
</tbody>
</tbody>

My goal is to run a script that check the indent on column A:A, copy the values of column B:B to Column C:C, but insert subtotal formula for some lines depending on the indent, in this example are "A"; "B"; "B.1".

Is this possible?

Thanks,
Gonçalo
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
A
7
=subtotal(9;B2:B4)
A.11
1
A.2
2
2
A.3
4
4
B
20
=subtotal(9;B6:B11)
B.1
8
=subtotal(9;B7:B9)
B.1.1
2
2
B.1.2
3
3
B.1.3
3
3
B.2
7
7
B.3
5
5

<tbody>
</tbody>

Sorry, i forgot to show one table with the example.

I have already this table but it is all values, and the values in bold are values and not "sum" or "subtotal".
My goal is to replace all the bold values with subtotal(9;....) formula. Instead of replace, i don't mind to have a new column, for example column "C", like the example.

Thanks,
Gonçalo
 
Upvote 0
Just checking a bit more ..

Before this process is started, does your column B look like you have shown in post 3 or does it look like my column B below, or something else?

By "indent" do you mean a physical indent in the cell like below (I have just used _ characters to force the look) or do you mean the suffixes like .1 or .1.1?

Does it have to be a SUBTOTAL formula or if another formula is possible to get the result could that be used?

Does it have to be done by vba or, if possible, a worksheet formula would do?

Excel Workbook
AB
1A
2_A.11
3_A.22
4_A.34
5B
6_B.1
7__B.1.12
8__B.1.23
9__B.1.33
10_B.27
11_B.35
12
Subtotal
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,769
Members
448,991
Latest member
Hanakoro

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