地址和引用,绝对和相对
相对地址
A1表示的是位于列A行1处的单元格。要描述一个单元格区域,只要在给出这个单元格区域左上角处的单元格位置后键入双引号,随后给出这个单元格区域右下角处的单元格位置即可。比如:由工作表左上角处的四个单元格所组成的单元格区域可以命名为A1:B2。
这种描述单元格区域的方式(A1:B2)是一个相对引用。在复制公式时,您必须对借助相对引用描述的单元格区域重新进行配置。
绝对地址
Absolute referencing is the opposite of relative addressing. A dollar sign is placed before each letter and number in an absolute reference, for example, $A$1:$B$2.
LibreOffice can convert the current reference, in which the cursor is positioned in the input line, from relative to absolute and vice versa by pressing F4. If you start with a relative address such as A1, the first time you press this key combination, both row and column are set to absolute references ($A$1). The second time, only the row (A$1), and the third time, only the column ($A1). If you press the key combination once more, both column and row references are switched back to relative (A1)
LibreOffice Calc shows the references to a formula. If, for example, you click the formula =SUM(A1:C5;D15:D24) in a cell, the two referenced areas in the sheet will be highlighted in color. For example, the formula component "A1:C5" may be in blue and the cell range in question bordered in the same shade of blue. The next formula component "D15:D24" can be marked in red in the same way.
什么时候使用相对引用,什么时候使用绝对引用?
相对引用有什么不同呢?假设您想在单元格 E1 中计算 A1:B2 区域中的单元格总和。输入 E1 的公式为:=SUM(A1:B2)。如果后来您又决定在 A 列前插入一个新列,要添加的元素在 B1:C2 中,公式在 F1 中,而不是在 E1 中。插入新列之后,您必须检查和更正该工作表或其他工作表中的所有公式。
幸运的是,LibreOffice 会替您完成此任务。插入新列 A 后,公式 =SUM(A1:B2) 将自动更新为 =SUM(B1:C2)。插入新行 1 时,行号也会自动调整。只要移动了引用区域,LibreOffice Calc 中的绝对引用和相对引用就会进行相应的调整。但是请注意,复制公式时只调整相对引用,而不会调整绝对引用。
当要引用工作表中的某一个单元格进行计算时,请使用绝对引用。如果您没有将单元格设定为绝对引用,那么,当将引用了此单元格的公式复制到源单元格下方的单元格中时,引用的单元格也将跟着下移。
除了插入新的行或列,将引用了特定单元格的现有公式复制到同一工作表的另一个区域中时,也会更改引用的单元格。假定您在第 10 行中输入了公式 =SUM(A1:A9)。如果要计算右边相邻列的总和,只需将此公式复制到右边的单元格中。复制到列 B 中的公式将自动改为 =SUM(B1:B9)。