位址和參照, 絕對和相對

相對定址

欄 A 以及列 1 的儲存格定位為 A1。您要指出和儲存格相連的區塊,可以指出該區域左上角的位址,然後輸入一個冒號,接著再輸入該區塊右下角儲存格的位址。這個左上角最前面四個儲存格的矩形區塊稱為 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)。