Aracılığıyla paylaş


NamedRange.ColumnDifferences(Object) Method

Definition

Gets a Range that represents all the cells whose contents are different from the comparison cell in each column.

public:
 Microsoft::Office::Interop::Excel::Range ^ ColumnDifferences(System::Object ^ Comparison);
public Microsoft.Office.Interop.Excel.Range ColumnDifferences (object Comparison);
abstract member ColumnDifferences : obj -> Microsoft.Office.Interop.Excel.Range
Public Function ColumnDifferences (Comparison As Object) As Range

Parameters

Comparison
Object

A single cell to compare to the specified range.

Returns

A Range that represents all the cells whose contents are different from the comparison cell in each column.

Examples

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

This example is for a document-level customization.

private void ShowColumnDifferences()
{
    Microsoft.Office.Tools.Excel.NamedRange columnDifferencesRange =
       this.Controls.AddNamedRange(this.Range["A1", "C5"],
       "columnDifferencesRange");
    this.Range["B1", "C3"].Value2 = 22;
    this.Range["B4", "C5"].Value2 = 11;
    Excel.Range range2 = columnDifferencesRange.ColumnDifferences(
        this.Range["B5"]);
    range2.Select();
}
Private Sub ShowColumnDifferences()
    Dim columnDifferencesRange As _
        Microsoft.Office.Tools.Excel.NamedRange = _
        Me.Controls.AddNamedRange(Me.Range("A1", "C5"), _
        "columnDifferencesRange")
    Me.Range("B1", "C3").Value2 = 22
    Me.Range("B4", "C5").Value2 = 11
    Dim range2 As Excel.Range = _
        columnDifferencesRange.ColumnDifferences(Me.Range("B5"))
    range2.Select()
End Sub

Applies to