View Single Post
 
Old 02-11-2018, 02:52 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Here's something I picked up many years ago which might fit your needs...

Code:
Public Sub SumDemo()
    Dim ColSumRng As Range, hdr As Variant
    Dim FirstEmptyRow As Long, SubTot As Long

    ' Goto each column header starting with column B
    For Each hdr In Range("A1:L1").SpecialCells(xlCellTypeConstants, 3)

        ' Find where data ends for the specific Column
        FirstEmptyRow = Cells(65536, hdr.Column).End(xlUp).Row + 1

        ' Subtotal all numbers for Column
        SubTot = Application.WorksheetFunction.Subtotal(9, Range(hdr.EntireColumn.Address))

        ' Put Subtotal at bottom of column
        Cells(FirstEmptyRow, hdr.Column).Value = SubTot

    Next hdr
End Sub
Reply With Quote