Hi
I have some code below that inserts a subtotal at the breaks I need. However. I can't seem to get it to be specific to the columns I want to subtotal. I have tried changing the numbers in
with no luck.
I also want it to exclude the Grand Total row with no luck. I have tried
in the last line of the code.
Can anyone help?
Thanks
Ian
I have some code below that inserts a subtotal at the breaks I need. However. I can't seem to get it to be specific to the columns I want to subtotal. I have tried changing the numbers in
Code:
For I = 3 To FinalCol
I also want it to exclude the Grand Total row with no luck. I have tried
Code:
RowGrand:= False
Can anyone help?
Thanks
Ian
Code:
Sub InsertSubtotals()
Dim TotColumns()
Dim I As Integer
FinalCol = Cells(3, 255).End(xlToLeft).Column
ReDim Preserve TotColumns(1 To FinalCol - 2)
For I = 3 To FinalCol
TotColumns(I - 2) = I
Next I
Selection.Subtotal GroupBy:=5, Function:=xlSum, TotalList:=TotColumns, Replace:=True, PageBreaks:=True, Summary