Merge Related Methods and Properties

It is quite common to create a merged cell (that is, a single cell created by combining several adjacent cells) for use as a title or heading, for instance.

The Merge method creates a merged cell from the specified range. The syntax is:


where Across is an optional Variant that should be set to True to merge the cells in each row of the range into a single cell per row or False (the default) to merge all cells in all rows into a single cell. Note that when the individual cells contain data, the merged cell will contain only the data from the upper-left cell. Hence, the data in all other cells will be lost.

The UnMerge method separates a merged area into individual cells. Its syntax is:


Note that as long as RangeObject contains any of the cells within a merged range, even if it does not contain all merged cells or if it contains additional cells not in the merged area, the method will unmerge the merged range. Note that calling the UnMerge method on a range that does not contain merged cells has no effect and does not produce a runtime error.

The MergeArea property applies only to ranges that consist of a single cell (otherwise an error occurs). The property returns a Range object representing the merged range containing that cell (or the cell itself if it is not part of a merged range).

Tea257 ly®

The MergeCells property returns True if the specified range is contained within a merged range of cells. The property returns Null if the specified range contains cells that are within a merged range as well as cells that lie outside the merged range.

0 0

Post a comment