Column Differences and Row Differences Methods

The ColumnDifferences method returns a Range object that represents all the cells in the range whose contents are different from certain comparison cells (there is one comparison cell in each column). The syntax is:

RangeObject.ColumnDifferences(ComparisonCell)

where ComparisonCell is a range object that represents a single cell. The purpose of ComparisonCell is simply to identify the row whose cells contain the comparison values.

To illustrate, consider the following code, whose results are shown in Figure 19-6:

Dim rng As Range, rng2 As Range Set rng = Range("A1:D6") Set rng2 = _

rng.ColumnDifferences(Comparison:=Range("A1")) rng2.Select

Figure 19-6. The result of the ColumnDifferences method

Figure 19-6. The result of the ColumnDifferences method

Since the ComparisonCell is cell A1, the first cell of each column in the range contains the comparison value. Thus, the cells that do not contain an "x" are selected in column A, the nonblank cells are selected in column B, the cells that do not contain a "y" are selected in column C and the cells that do not contain an "a" are selected in column D.

The RowDifferences method is the analog for rows of the ColumnDifferences method.

+5 0

Responses

  • helen
    What is RowDifferences in vba?
    7 years ago

Post a comment