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
Bookmarks