Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-11-2018, 02:52 PM
jeffreybrown jeffreybrown is offline Insert a Variable Row to SUM SubTotal Windows Vista Insert a Variable Row to SUM SubTotal 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
 

Tags
insert sum last row



Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable shimulsiddiquee Excel 1 05-16-2017 07:39 AM
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge Berryblue Mail Merge 1 11-13-2014 05:36 PM
Insert a Variable Row to SUM SubTotal Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM
Insert a Variable Row to SUM SubTotal Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM
Each subtotal signature require only at last page for each subtotal. aligahk06 Excel 0 05-07-2010 11:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft