ITabRange.DependenceCells

Syntax

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

Parameters

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

If the parameter value is True, the cells which directly determine the selected cell are to be found (the formula of the selected cell contains a direct link to the cell).

If the parameter value is False, all the cells which directly or indirectly determine the selected cell are to be found.

Description

The DependenceCells method finds cells, which determine the selected cell.

Comments

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

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

NOTE. A compound range is created based on the cells of one cell. The number of array items corresponds to the number of tables containing the cells, that determine the way the current cell is calculated.

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.

Add links to the Drawing, Report, Tab, Metabase system assemblies.

    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.DependenceCells(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
                Debug.WriteLine("Dependent cells are not found.");
            End If;
        Else
            Debug.WriteLine("Only one cell should be selected.");
        End If;
    End Sub Button1OnClick;

On clicking the button, all cells that determine the currently selected cell, are to be found. The borders of found cells are shown as a red line.

See also:

ITabRange