Worksheet.CircularReference Property (2007 System)

Gets a Range object that represents the range containing the first circular reference on the sheet, or gets nulla null reference (Nothing in Visual Basic) if there is no circular reference on the sheet.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property CircularReference As Range
'Usage
Dim instance As Worksheet 
Dim value As Range 

value = instance.CircularReference
[BrowsableAttribute(false)]
public Range CircularReference { get; }
[BrowsableAttribute(false)]
public:
property Range^ CircularReference {
    Range^ get ();
}
public function get CircularReference () : Range

Property Value

Type: Range
A Range object that represents the range containing the first circular reference on the sheet; nulla null reference (Nothing in Visual Basic) if there is no circular reference on the sheet.

Remarks

The circular reference must be removed before calculation can proceed.

Examples

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 Sub HasCircularReference()
    Me.Range("A1").Formula = "=B1" 
    Me.Range("B1").Formula = "=A1" 

    If Me.CircularReference Is Nothing Then
        MsgBox("This worksheet has no circular references")
    Else
        MsgBox("The worksheet has a circular reference at: " & _
            Me.CircularReference.Address( _
            ReferenceStyle:=Excel.XlReferenceStyle.xlA1))
    End If 
End Sub
private void HasCircularReference()
{
    this.Range["A1", missing].Formula = "=B1";
    this.Range["B1", missing].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(missing, missing,
            Excel.XlReferenceStyle.xlA1, missing, missing));
    }
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace