Ruchi_Sas
asked on
passing array in subtotal
I need to pass array in subtotal
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array( 1 to lastcolumn ), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
I am doing the above fn. Please help and let me know how to pass 1 to lastcoulmn in this array
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array( 1 to lastcolumn ), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
I am doing the above fn. Please help and let me know how to pass 1 to lastcoulmn in this array
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
something like this with the last column (you can't put the first column since you're grouping on it)
Sub Macro3()
'
' Macro3 Macro
Dim arrSeries(), lgMin As Long, lgMax As Long
lgMin = 2
lgMax = Cells(1, Columns.Count).End(xlToLeft).Column
ReDim Preserve arrSeries(lgMax - lgMin)
For i = lgMin To lgMax
arrSeries(i - lgMin) = i
Next
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=arrSeries, Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub
ASKER