Excel automation - subtotals

Created by Mike James, Modified on Mon, 13 Jan at 10:55 AM by Mike James


// Where XL is a workbook open using Excel automation

// and workbook with a data matrix is open


XLsum is int = -4157 // cannot just use -4157 as a parameter of the subtotal function

arrColumns is array of int 

    

    // Add subtotals


arrColumns = [8,9,10]

// this does not work - error "unable to find subtotal property of range"

//XL>>Sheets(n)>>Range("Data")>>Subtotal(1,-4157,arrColumns,True,False,True)  // -4157 = xlsum

// this works :)

XL>>Sheets(n)>>Range("A1")>>Subtotal(1,XLsum,arrColumns,True,False,True)  // -4157 = xlsum

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article