Consulting

Results 1 to 7 of 7

Thread: Sleeper: Subtotal

  1. #1
    VBAX Regular
    Joined
    Aug 2005
    Posts
    77
    Location

    Sleeper: Subtotal

    how to use subtotal in VB?
    .Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2, 3)
    what mean every part in this method?!
    i understand only the function: part

    If i have autofiltered data range("K2:K355") how i use subtotal?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    GroupBy Required Long. The field to group by, as a one-based integer offset. For more information, see the example.

    TotalList Required Variant. An array of 1-based field offsets, indicating the fields to which the subtotals are added. For more information, see the example.

    You need to tell Excel what column to group by, and what column to add up for each group. So what column has your categories that you want to group, and is K your values?

    Maybe post your workbook and we can get the setting correct for you.

  3. #3
    VBAX Regular
    Joined
    Aug 2005
    Posts
    77
    Location
    I have look this excel subtotal help but maiby is my english so bad and i dont understand this example there.
    Ok i want use subtotal one part of this tread explained probelm
    http://www.vbaexpress.com/forum/showthread.php?t=5353

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Assuming you want to group by Col B and sum Col K then...

    B=2 (2nd Column)
    K=11 (11th Column)


    Range("A1:N355").Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(11), _
            Replace:=True, PageBreaks:=False, SummaryBelowData:=True

  5. #5
    VBAX Regular
    Joined
    Aug 2005
    Posts
    77
    Location
    Quote Originally Posted by DRJ
    Assuming you want to group by Col B and sum Col K then...

    B=2 (2nd Column)
    K=11 (11th Column)


    Range("A1:N355").Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(11), _
            Replace:=True, PageBreaks:=False, SummaryBelowData:=True
    Ok now i understand subtotal method but is possible without GroupBy and using the GrandTotal value in VB or sum only K column

    Another question how to remove subtotal after calculatins

  6. #6
    VBAX Regular
    Joined
    Aug 2005
    Posts
    77
    Location
    Any idea remove subtotal rows after calculations?

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    To remove the subtotals...


    Range("A:N").RemoveSubtotal

Posting Permissions

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