Subtotals in Excel

I want to create subtotals in excel using the excel subtotals utility If you play the macro while putting a subtotal, the next code is generated in VB: Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(5, 7, 10), _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True So, trying to translate this to navision it look like this: autSheet.Range(‘A1’).Subtotal(1,-4157,5,TRUE,FALSE,1); Explanation: For every change in column 1 make a sum of column 5 This works fine, but when I want select more columns to sum I get an excel integration error. The problem is that TotalList contains an array and within navision I can not pass this array argument autSheet.Range(‘A1’).Subtotal(1,-4157,‘5 ,7,10’,TRUE,FALSE,1); → Error excel integration I’ ve already tried to declare a variant with dimensions 50 and change my code to varArray[1] := 5; varArray[2] := 7; varArray[3] := 10; autSheet.Range(‘A1’).Subtotal(1,-4157,varArray,TRUE,FALSE,1) but then following error appear: The array dimensions must be identical [:(]

Did you try to just send the formula as text? I normally do it this way, Excel automatically looks at text and trys to turn it into a formula.

Passing the colums I want to sum as text give an automation error while running the program. Thanks for you reply.

if possible try to simulate the process in VBA. Much better debugger to find logic errors.