How do you copy a formula down a column with the org-mode spreadsheet
My personal preference is to add a column formula directly into the cell, instead of having to remember so many keyboard shortcuts.
Just start typing into the cell, starting with a =
sign. For example, in column 3 type =$1+$2
and that formula will apply to all of the column directly.
You need to C-c C-c
to actually apply the formula and calculate results.
For a single cell (non-column) formula, start with :=
instead.
What you are looking for is to use C-3 C-c =
where 3
is the number of rows you want the formula to apply to.
| 3 | 4 | |
| 2 | 8 | |
If I C-2 C-c =
in the column after the 4
. I can input my formula of $1+$2
which will cascade down to each row, giving me the result of
| 4 | 3 | 7 |
| 2 | 8 | 10 |
#+TBLFM: $3=$1+$2
You are also free to just add #+TBLFM: $3=$1+$2
to the bottom of your table. You can force the formula to revaluate its values with C-c C-c
when your point is anywhere over the formula.
C-u C-c C-c
re-applies all formulas.
For example, given
| 3 | 4 | _ |
| 2 | 8 | |
| 1 | 12 | |
(where _
marks the location of the cursor) you could type C-c =
1, then enter a formula such as
$3=$1+$2
So the table looks like:
| 3 | 4 | 7 |
| 2 | 8 | |
| 1 | 12 | |
#+TBLFM: $3=$1+$2
Now typing C-u C-c C-c
yields
| 3 | 4 | 7 |
| 2 | 8 | 10 |
| 1 | 12 | 13 |
1Alternatively, use C-c '
to open a formula editing buffer, write and/or edit the formulas, then close the buffer (with C-x
C-s
) instead. I find this more convenient since you can use all emacs commands in the buffer, instead of just the limited set you can use in the minibuffer.