# Adding Formulas to Calculate Balances

This topic provides you steps to add formulas to calculate balances in the checkbook register using Spread for ASP.NET.

## Content



Your checkbook register is now set up to look like a checkbook register; however, it does not balance the currency figures you enter in the register. This step sets up the formula for balancing the figures.

1.  Below the code you have already added, add the following code:
    
    ```csharp
    // Set formula for calculating balance.
    FpSpread1.Sheets[0].ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;
    FpSpread1.Sheets[0].Cells[0, 7].Formula = "RC[-1]-RC[-2]";
    for (int i = 1; i < 99; i++)
    {
      FpSpread1.Sheets[0].Cells[i, 7].Formula = "R[-1]C-RC[-2]+RC[-1]";
    }
    ```
    
    ```vbnet
    ' Set formula for calculating balance.
    FpSpread1.Sheets(0).ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1
    FpSpread1.Sheets(0).Cells(0, 7).Formula = "RC[-1]-RC[-2]"
    Dim i As Integer
    For i = 1 To 99
      FpSpread1.Sheets(0).Cells(i, 7).Formula = "R[-1]C-RC[-2]+RC[-1]"
    Next
    ```
    
2.  Save your project, then from the **Debug** menu choose **Start** to run your project.

Your ASP.NET page should look similar to the following picture. Type data into your checkbook register to test it and see how it operates. Click on the checkmark icon to save the changes or set the **ClientAutoCalculation** property for the control to **True**.

![Completed Checkbook Register](https://cdn.mescius.io/document-site-files/images/346c9178-0ed8-4fb9-908b-1565b22fb408/artwork/chckbk4.png)

Your checkbook register is complete! You have completed this tutorial.