WorksheetBase.CircularReference Property

 

Gets a Range object that represents the range containing the first circular reference on the sheet, or gets null if there is no circular reference on the sheet.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public Range CircularReference { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range

A Range object that represents the range containing the first circular reference on the sheet; null if there is no circular reference on the sheet.

The circular reference must be removed before calculation can proceed.

The following code example creates a circular reference by setting the formulas of cells A1 and B1 to resolve to the value of each other. The example then uses the CircularReference property to report whether the worksheet has a circular reference.

This example is for a document-level customization.

private void HasCircularReference()
{
    this.Range["A1"].Formula = "=B1";
    this.Range["B1"].Formula = "=A1";

    if (this.CircularReference == null)
    {
        MessageBox.Show("This worksheet has no circular references");
    }
    else
    {
        MessageBox.Show("The worksheet has a circular reference at: " +
            this.CircularReference.get_Address(Excel.XlReferenceStyle.xlA1));
    }
}
Return to top
Show: