I want to automate the subtotal function by using VBA macro but do not know how to cope with an expanding range of columns in the macro. The following is the code, so far, to run the subtotal function, where the array states the numbers of the columns to be sub-totalled. The columns will increase linearly from 8.
Code
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(5, 6, 7, 8) _
, Replace:=True, PageBreaks:=False, SummaryBelowData:=True
can anyone give me a pointer please?