NamedRange.ColumnDifferences Method
Gets a Range that represents all the cells whose contents are different from the comparison cell in each column.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Syntax
'Declaration
Function ColumnDifferences ( _
Comparison As Object _
) As Range
Range ColumnDifferences(
Object Comparison
)
Parameters
Comparison
Type: System.ObjectA single cell to compare to the specified range.
Return Value
Type: Range
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 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
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();
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.