Merging a Range

The range class can be the target of the merge and unmerge commands.

merge  : Merge a specified range of cells.

merge range

unmerge  : Unmerge all merged the cells in a specified range.

unmerge range

The merging of cells is often done for organizational or esthetic reasons, as a way to separate or highlight data in a table. In the example table shown below, alternating rows have been merged to provide a buffer between the rows that will contain the data.

merged-row-table

NOTE: You can merge cells wholly within a table header region or the body. You cannot merge cells that span those regions. e.g. If you set the number of header columns to 5 then merge range "A1:E1" will work but merge range "A1:F1" will not, because F1 is in the body and the others are in the header.

The following example script will create such a table on the current spread of the frontmost document:

TOP | CONTINUE