Range Coordinates

In Numbers, a range is defined and represented by its coordinates. A range’s coordinates are typically represented as a text string of two cell names (addresses), delimited by a colon character. For example: "C4:G7". A coordinate pairing means: a range encompassing every contiguous cell from the first cell of the pairing to the last cell of the pairing.

A range can be selected in a table by assigning the range as the value of table’s selection range property.

set selection range of table 1 to range "H5:K8"

This will cause the defined range to become the selection of the targeted table.  (⬇ see below ) 

example-range-selection

IMPORTANT: Although a table selection may be useful to provide feedback to the script user, it is not necessary to actually have the script select a range first, in order to modify its contents, or change the values of its properties. Such tasks can be accomplished by simply targeting the defined range in a script.  (⬇ see below ) 

set the color of range "H5:K8" of table 1 to {65535, 0, 0}

Deriving Ranges

Range coordinates can be derived by scripts, using any of the following methods.

1) Opposing Corners

Combining the name of the top left cell of the range, a colon character (:) delimiter, and the name of the bottom right cell of the range, and preceding the combined text string with the class name range. For example: range "C4:G7"

All of the following script examples use the assume that a reference to a specific table is contained by the variable thisTable:

tell thisTable
 set the selection range to range "C4:G7"
end tell

(the corner cells have been colorized for visual effect)

range-selection-01

2) Row Reference

To target a whole single row, use the value of the row name or index properties to address the range of cells contained by the row.

tell thisTable
 set the selection range to row "5"
end tell

single-row-selected

3) Column Reference

To target a whole single column, use the value of the column name or index properties to address the range of cells contained by the column.

tell thisTable
 set the selection range to column "H"
end tell

single-column-selected

4) Multiple Columns

To target a multiple contiguous columns, use the opposing corners technique, referencing the two corner cells by their relative position in their columns.

tell thisTable
 set thisRangeName to ¬
 ((name of the first cell of column "C") & ":" & ¬
 (name of the last cell of column "E"))
 set the selection range to range thisRangeName
end tell

You can also create a range for a contiguous group of full columns by using their names, like this:

tell thisTable
 set thisRangeName to "C:E"
 set the selection range to range thisRangeName
end tell

select-contiguous-columns

5) Multiple Rows

To target a multiple contiguous rows, use the opposing corners technique, referencing the two corner cells by their relative position in their rows.

tell thisTable
 set thisRangeName to ¬
 ((name of first cell of row "4") & ":" & (name of last cell of row "6"))
 set the selection range to range thisRangeName
end tell

You can also create a range for a contiguous group of full rows by using their names, like this:

tell thisTable
 set thisRangeName to "4:6"
 set the selection range to range thisRangeName
end tell

select-contiguous-rows

6) Entire Table

To target all of the table’s cells, set the value of the table’s selection range property to the value of the table’s cell range property.

tell thisTable
 set the selection range to the cell range
end tell

all-cells-selected

TOP | CONTINUE