Results 1 to 12 of 12

Macro for multiple subtotals

Threaded View

  1. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,659

    Re: Macro for multiple subtotals

    Try the attached
    Sub test()
        Dim r As Range, i As Long
        Application.ScreenUpdating = False
        Columns("e").Insert
        With Range("d3", Range("d" & Rows.Count).End(xlUp)).Offset(, 1)
            .Formula = "=if(d2<>d3,if(e1=2,""a"",1),"""")"
            .Value = .Value
            On Error Resume Next
            For i = 1 To 2
                .SpecialCells(2, 1).EntireRow.Insert
                .SpecialCells(2, 2).EntireRow.Insert
            Next
            On Error GoTo 0
        End With
        Columns("e").Delete
        With Columns("j").SpecialCells(2, 1)
            For Each r In .Areas
                r(r.Count + 1).Formula = "=subtotal(9," & r.Address & ")"
            Next
        End With
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Add Multiple Subtotals
    By pociners in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-25-2014, 05:12 AM
  2. [SOLVED] subtotals with multiple layers
    By plamb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-25-2013, 02:20 PM
  3. Macro to apply subtotals to multiple sheets
    By Scotbot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2012, 09:10 AM
  4. [SOLVED] Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. [SOLVED] Subtotals multiple columns
    By Gary L Brown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  6. Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. [SOLVED] Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1