ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please help -Columns Array in SubTotals (https://www.excelbanter.com/excel-programming/394288-please-help-columns-array-subtotals.html)

michael.beckinsale

Please help -Columns Array in SubTotals
 
Hi All,

I think this should be pretty straightforward but the answer is
eluding me. Its a Friday and l am tired!

I want to apply subtotals to a range using VBA the rub being that the
1st column for the subtotals is variable (say column 8 (H) in this
example) and the last column will always be +90 (98 in this example)

My idea was to find the 1st & last column number, create an array and
assign to an array variable to use in the subtotal function.

Please help, l am failing miserably!

Sample code ----- DOES NOT WORK

Sub SP_SubTotals()

Dim STArray(8 To 98) this to be replaced by LC(last column)

Sheets("Staff Planner").Activate
Range(Cells(4, 1), Cells(LR, LC)).Select
Selection.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=(STArray),
_
Replace:=True, PageBreaks:=False, SummaryBelowData:=True

End Sub

TIA

Michael Beckinsale



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com