Expand Minimize

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)

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.

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 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();
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft