We have found this issue where we get a extra row between the last group and the last subtotal formula row when we apply a subtotal to a known range. This seems to be causing an issue when we try to apply another subtotal to the subtotaled range.
I have attached a small project to demonstrate the issue. I have also attached an input file “input with a named ranged called TargetTable.xlsx” which contains a named range called “TargetTable”.
The code calls the Worksheet.Cells.Subtotal() method to apply the the subtotaling setting to the named range. I have caught the exception and saved the file when it fires (search for “Unknown object is null?” in Form1.cs).
If you run the project code to the end the following files will be created in the order:
- “Subtotalling test_Tables converted to Named Range .xlsx”
If you look at the files 3-5 you will notice that the last group only has one subtotal row.