VBA subtotal depending on indent
Results 1 to 4 of 4

Thread: VBA subtotal depending on indent
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Feb 2015
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA subtotal depending on indent

    Hi,

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


    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

  2. #2
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,463
    Post Thanks / Like
    Mentioned
    86 Post(s)
    Tagged
    19 Thread(s)

    Default Re: VBA subtotal depending on indent

    Quote Originally Posted by jocker_boy View Post
    Is this possible?
    Quite likely, but some more specific detail about exactly what you have, where and what result you want, where would help.
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  3. #3
    New Member
    Join Date
    Feb 2015
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA subtotal depending on indent

    A
    7
    =subtotal(9;B2:B4)
    A.1 1 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

    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

  4. #4
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,463
    Post Thanks / Like
    Mentioned
    86 Post(s)
    Tagged
    19 Thread(s)

    Default Re: VBA subtotal depending on indent

    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?

    Subtotal

    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


    Excel tables to the web >> Excel Jeanie HTML 4
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •