# Recalculating and Updating Formulas Automatically

Learn how to automatically recalculate and update formulas in your spreadsheet with our comprehensive guide.

## Content

## Auto Calculation

By default, Spread allows you to recalculate the formulas in the cells when the values of the dependent cells change. The value in dependent cells changes in following scenarios:

* Adding, inserting or removing any row/column
* Moving/swapping the block of cells
* On saving/loading a spreadsheet having formulas in cells.

The [AutoCalculation ](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.AutoCalculation.html)property is enabled automatically whenever there is a change of value in the dependent cells and auto calculation of formulas in cells occurs. However, you can disable this property to prevent automatic calculations in cells.

> Note: This property does not control the automatic calculation of formulas while saving/loading a spreadsheet.

In case you wish to enable/disable the automatic calculation of formulas while saving/loading a spreadsheet even when the values in dependent cells change, you can use the [CalculateBeforeSave ](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.CalculationEngine.CalculateBeforeSave.html)property. The default value of the CalculateBeforeSave property is true.

## Suspend Calculation

Additionally, you can also suspend the calculation of formulas in cell by using the [SuspendCalculation ](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.CalculationEngine.SuspendCalculation.html)property, so that the cell containing formula is not updated whenever there is a change in value in dependent cells. The default value of the SuspendCalculation property is false. This property works for suspending calculations while saving/loading a spreadsheet.

> Note: Once the calculations are suspended, use the [RecalculateAll()](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.RecalculateAll.html) method to recalculate the formulas in cells.

Following code is used to disable the automatic calculation of formulas in cells while saving/loading a file.

```csharp
private void Form1_Load(object sender, EventArgs e)
 {
    IWorksheet sheet = fpSpread1.AsWorkbook().ActiveSheet;
    fpSpread1.Sheets[0].AutoCalculation = false;
    sheet.Cells["B2"].Value = 1;
    sheet.Cells["C2"].Formula = "B2";
 }

private void saveBtn_Click(object sender, EventArgs e)
 {
     fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalculateBeforeSave = false;
     fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.SuspendCalculation = true;
     fpSpread1.Sheets[0].Cells["B2"].Value = 50;
     
     // For recalculating again
     //fpSpread1.ActiveSheet.RecalculateAll();
     fpSpread1.SaveExcel("D:\\SampleCalculation.xlsx", ExcelSaveFlags.UseOOXMLFormat);
     
 }

private void loadBtn_Click(object sender, EventArgs e)
 {
     fpSpread1.OpenExcel("D:\\SampleCalculation.xlsx");
 }
```

```vbnet
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Dim sheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
      FpSpread1.Sheets(0).AutoCalculation = False
      sheet.Cells("B2").Value = 1
      sheet.Cells("C2").Formula = "B2"
  End Sub

  Private Sub saveBtn_Click(sender As Object, e As EventArgs) Handles saveBtn.Click
      FpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalculateBeforeSave = False
      FpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.SuspendCalculation = True
      FpSpread1.Sheets(0).Cells("B2").Value = 50
      
     'For recalculating again
     'FpSpread1.ActiveSheet.RecalculateAll()
      FpSpread1.SaveExcel("D:\SampleCalculation.xlsx", ExcelSaveFlags.UseOOXMLFormat)   
  End Sub

  Private Sub loadBtn_Click(sender As Object, e As EventArgs) Handles loadBtn.Click
     FpSpread1.OpenExcel("D:\SampleCalculation.xlsx")
  End Sub
```

## See Also

[Formulas in Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula)
[Placing a Formula in Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulaplace)
[Specifying a Cell Reference in a Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulacellref)
[Specifying a Sheet Reference in a Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulasheetref)
[Specifying an External Reference in a Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-externalref)
[Using a Circular Reference in a Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulacircref)
[Nesting Functions in a Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulanested)
[Finding a Value Using GoalSeek](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formula-goalseek)
[Allowing the User to Enter Formulas](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulaallowuser)
[Creating and Using a Custom Name](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulacustomname)
[Creating and Using a Custom Function](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulacustomfunc)
[Creating and Using External Variable](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-external-variable)
[Using the Array Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-arrayformula)
[Working with the Formula Text Box](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-formulabar)
[Setting up the Name Box](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-namebox)
[Using Language Package](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/UsingLanguagePackage)
[Accessing Data from Header or Footer](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-headerfooterformula)
[Managing External Reference](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/spwin-extrenalreference)
[Working With Dynamic Array Formulas](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula/WorkingWithDynamicArrayFormulas)