NamedRange.RowDifferences Method

Gets a Microsoft.Office.Interop.Excel.Range object that represents all the cells whose contents are different from those of the comparison cell in each row.

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

Syntax

'Declaration
Function RowDifferences ( _
    Comparison As Object _
) As Range
Range RowDifferences(
    Object Comparison
)

Parameters

  • Comparison
    Type: System.Object

    A single cell to compare with the other cells in the row.

Return Value

Type: Microsoft.Office.Interop.Excel.Range
A Microsoft.Office.Interop.Excel.Range object that represents all the cells whose contents are different from those of the comparison cell in each row.

Examples

The following code example creates a NamedRange and populates cells in the range with three different values. It compares all of the cells in the NamedRange with the value of cell B5, which is 22, and selects the cells that contain values that do not match.

This example is for a document-level customization.

Private Sub ShowRowDifferences()
    Dim rowDifferencesRange As _
        Microsoft.Office.Tools.Excel.NamedRange = _
        Me.Controls.AddNamedRange(Me.Range("A1", "C5"), _
        "rowDifferencesRange")
    Me.Range("A1", "A5").Value2 = 11
    Me.Range("B1", "B5").Value2 = 22
    Me.Range("C1", "C5").Value2 = 33
    Dim range2 As Excel.Range = _
        rowDifferencesRange.RowDifferences(Me.Range("B5"))
    range2.Select()
End Sub
private void ShowRowDifferences()
{
    Microsoft.Office.Tools.Excel.NamedRange rowDifferencesRange =
       this.Controls.AddNamedRange(this.Range["A1", "C5"],
       "rowDifferencesRange");
    this.Range["A1", "A5"].Value2 = 11;
    this.Range["B1", "B5"].Value2 = 22;
    this.Range["C1", "C5"].Value2 = 33;
    Excel.Range range2 = rowDifferencesRange.RowDifferences(
        this.Range["B5"]);
    range2.Select();
}

.NET Framework Security

See Also

Reference

NamedRange Interface

Microsoft.Office.Tools.Excel Namespace