ITabRange.DependentCells

Syntax

DependentCells([DirectOnly: Boolean = True]): Array;

Parameters

DirectOnly. The parameter that determines a method that is used to find dependent cells.

If parameter is set to True, the method searches for all cells that directly depend on the given cell (Cells' formulas directly reference the given cell).

If parameter is set to False, the method finds all cells that directly or indirectly depend on the given cell.

Description

The DependentCells method finds cells that depend on the given cell.

Comments

The method can be executed only for a single-cell range.

An array is created as a result of method execution. Each cell of the array contains a compound cell range formulas of which reference the current cell.

Comment. A compound range is created based on the cells of one cell. The number of array elements matches the number of tables cells of which reference the given cell.

Example

Executing the example requires a form with the Button1 button located on it, the UiReport component named UiReport1, and the ReportBox component, that displays data of the regular report linked to UiReport1.

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        Sheet: IPrxTable;
        Cell, DepRange, DepCell: ITabRange;
        Style: ITabCellStyle;
        Arr: Array Of Variant;
        i, j: Integer;
    Begin
        Sheet := (UiReport1.Instance As IPrxReport).ActiveSheet As IPrxTable;
        Cell := Sheet.TabSheet.View.Selection.Range;
        If Cell.Count = 1 Then
            Arr := Cell.DependentCells(False);
            If Not IsNull(Arr) And (Arr.Length > 0Then
                For i := 0 To Arr.Length - 1 Do
                    DepRange := Arr[i] As ITabRange;
                    For j := 0 To DepRange.PartCount - 1 Do
                        DepCell := DepRange.Part(j);
                        Style := DepCell.Style;
                        Style.BorderColor(TabBorder.Outline) := GxColor.FromName("Red");
                        Style.BorderStyle(TabBorder.Outline) := TabBorderStyle.Continuous;
                    End For;
                End For;
            Else
                WinApplication.InformationBox("Could not find dependent cells.");
            End If;
        Else
            WinApplication.ExclamationBox("A single cell must be selected.");
        End If;
    End Sub Button1OnClick;

Click the button to find all cells that depend on the currently selected cell. The borders of found cells are shown as a red line.

See also:

ITabRange