+ Reply to Thread
Results 1 to 1 of 1

Modify code to create and format SUBTOTALS.

Hybrid View

Pete123abc Modify code to create and... 05-26-2011, 11:55 AM
  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    Illinois
    MS-Off Ver
    2007-2010
    Posts
    22

    Modify code to create and format SUBTOTALS.

    Slight modification to my earlier post:
    The code below hoses my print range. Need just the range that contains actual data with headings and subtotal labels. It wants to go to 38 pages, most of which are blank

    Have located the following code, and it comes really close to doing what we need; except for the following:
    It does not create a "Grand Total" beneath the last row. We'd like that.
    In addition, need to enter a thin line above each subtotaled line, and a double line above the Grand Total line. And for some reason it also does not bold the last subtotal in column 15.

    (Have tried CF within a recorded macro on lines containing the word total, but it creates an error at the word bold.)

    Thanks for any troubleshooting help on this one.
    Pete
    Sub CreateSubtotals()
    Dim wsh As Worksheet
    Dim i As Long, lRow As Long
    For Each wsh In ActiveWorkbook.Worksheets
    wsh.UsedRange.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(15), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=True
    lRow = wsh.Cells(Rows.Count, 1).End(xlUp).Row
    For i = lRow To 1 Step -1
    If InStr(wsh.Cells(i, 2), "Total") > 0 Then
    wsh.Cells(i, 15).Font.Bold = True
    wsh.Cells(i + 1, 2).EntireRow.Insert
    End If
    Next
    Next wsh
    End Sub
    Last edited by Pete123abc; 05-26-2011 at 01:05 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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