Next: , Previous: The print area, Up: Advanced Features

3.2 Ranges in formulas

A formula like

     (+ A1 A2 A3)

is the sum of three specific cells. If you insert a new second row, the formula becomes

     (+ A1 A3 A4)

and the new row is not included in the sum.

The macro (ses-range from to) evaluates to a list of the values in a rectangle of cells. If your formula is

     (apply '+ (ses-range A1 A3))

and you insert a new second row, it becomes

     (apply '+ (ses-range A1 A4))

and the new row is included in the sum.

While entering or editing a formula in the minibuffer, you can select a range in the spreadsheet (using mouse or keyboard), then paste a representation of that range into your formula. Suppose you select A1-C1:

Inserts "A1 B1 C1" (ses-insert-range-click)
C-c C-r
Keyboard version (ses-insert-range).
Inserts "(ses-range A1 C1)" (ses-insert-ses-range-click).
C-c C-s
Keyboard version (ses-insert-ses-range).

If you delete the from or to cell for a range, the nearest still-existing cell is used instead. If you delete the entire range, the formula relocator will delete the ses-range from the formula.

If you insert a new row just beyond the end of a one-column range, or a new column just beyond a one-row range, the new cell is included in the range. New cells inserted just before a range are not included.