We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Sub DoTasks() Dim cell As Range Dim total As Integer Dim rows_in_col As Integer Dim header As Range 'Find cells in header If Range("F5") = "" Then 'May only be one cell in header Set header = Range("E5") Else Set header = Range(Range("F5"), Range("F5").End(xlToRight)) End If 'Find the max row For Each cell In header rows_in_col = Range(cell, cell.End(xlDown)).Count If rows_in_col > total Then total = rows_in_col End If Next cell 'Add the sum column two rows below max For Each cell In header Cells(cell.Row + total + 1, cell.Column).Formula = "=@subtotal(9," & _ Range(cell, cell.End(xlDown)).Address & ")" Next cell 'Same command as double clicking the border. Range("A:S").EntireColumn.AutoFit Cells(header.Row + total + 1, 1).Activate End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.