WorksheetBase.CircularReference Property
Visual Studio 2012
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.
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
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)); } }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.