Dynamic formula to calculate the total of a column

Hello,

I am trying to calculate the total of a column using the following dynamic formula: &==SUM(A2:A{-1})

It gives me a runtime error complaining about the incorrect formula. All I am trying to achieve is have a range of A2:A(r-1) summed up.

Please help. Thanks.

Which version are you using? This feature is only available in recent versions. Please download and try v2.8.5 at

Hi Laurence,

thank you for your reply. The version I am using is Excel.Express, the latest one. Are there any plans to include this functionality in the Express version? Thank you.

The latest version of Aspose.Excel.Express is v1.2.1. It has already included this feature. Please download it at

You guys rock - problem solved. Thanks very much. I am impressed.

@mbrijun,
Aspose.Excel is discarded and no more under active development now. We have introduced a new product Aspose.Cells that is much more advanced and better in performance when compared to its predecessor. A better formula calculation engine is embedded in Aspose.Cells. It not only recalculates existing formulas but it also calculates formulas added at runtime. Following example demonstrates this feature:

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET

//Instantiating a Workbook object
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

//Adding a value to "A1" cell
worksheet.Cells["A1"].PutValue(1);

//Adding a value to "A2" cell
worksheet.Cells["A2"].PutValue(2);

//Adding a value to "A3" cell
worksheet.Cells["A3"].PutValue(3);

//Adding a SUM formula to "A4" cell
worksheet.Cells["A4"].Formula = "=SUM(A1:A3)";

//Calculating the results of formulas
workbook.CalculateFormula();

//Get the calculated value of the cell
string value = worksheet.Cells["A4"].Value.ToString();

//Saving the Excel file
workbook.Save("Adding Formula.xls");

For more details on working with formulas in Excel files, refer to the following articles:
Calculate or Recalculate formulas dynamically
Formula

Download the latest version for trial purpose here:
Aspose.Cells for .NET (Latest Version)

A ready to run solution can be downloaded here to test variety of features in this new product.