View Single Post
 
Old 02-11-2018, 12:26 PM
ChrisOK ChrisOK is offline Windows 7 64bit Office 2016
Advanced Beginner
 
Join Date: Sep 2016
Posts: 54
ChrisOK is on a distinguished road
Question Insert a Variable Row to SUM SubTotal

Need the code to find the last row of content on ACTIVE SHEET, then jump down +1 to place Subtotals beneath all the columns that exist; Bolding them would be helpful.

Hoping it can be 'variable' in the sense it's knows where to place the subtotals regardless of the size of the content table... in other words, to work with various files as some sheets might have 5 columns and 50 rows... the next sheet to use it on might have 25 columns and 100 rows.. the code isn't fixed/restricted to a constant range..

FOR EXAMPLE:
If current active sheet has 10 columns
20 rows
1st row is a title row
so SUMS would appear on the 21st row in this scenario

I'm using this awesome code by Jindon to extract content from a master report and place it onto a new tab. Now, I realize I need to have a final action initiate the placement of subtotals..
Code:
Sub test()
    With Sheets("extd").Cells(1).CurrentRegion
        .Parent.AutoFilterMode = False
        .AutoFilter 14, "x"
        If .Columns(1).SpecialCells(12).Count > 1 Then
            .Copy Sheets.Add(after:=.Parent).Cells(1)
        End If
        .AutoFilter
        Columns.Autofit 'added this to size columns
    End With
End Sub
Small sample file attached:
There's a 3rd module I added to test other SubTotaling code but can't get it working - (not married to it - but if it's useful as a start - I left for viewing)
Attached Files
File Type: xlsm Test-IF-x-copy-row-new-sheet.xlsm (78.4 KB, 13 views)
Reply With Quote