summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/scalc/guide/relativ_absolut_ref.xhp
blob: e302c97141cfde07e83f3fcf8be8a5230f918862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->
<helpdocument version="1.0">
<meta>
<topic id="textscalcguiderelativ_absolut_refxml" indexer="include" status="PUBLISH">
<title id="tit">Addresses and References, Absolute and Relative</title>
<filename>/text/scalc/guide/relativ_absolut_ref.xhp</filename>
</topic>
<history>
<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
</history>
</meta>
<body>
<bookmark branch="index" id="bm_id3156423"><bookmark_value>addressing; relative and absolute</bookmark_value>
<bookmark_value>references; absolute/relative</bookmark_value>
<bookmark_value>absolute addresses in spreadsheets</bookmark_value>
<bookmark_value>relative addresses</bookmark_value>
<bookmark_value>absolute references in spreadsheets</bookmark_value>
<bookmark_value>relative references</bookmark_value>
<bookmark_value>references; to cells</bookmark_value>
<bookmark_value>cells; references</bookmark_value>
<bookmark_value>range of cells; defining</bookmark_value>
<bookmark_value>cell references;ranges union</bookmark_value>
<bookmark_value>cell references;ranges concatenation</bookmark_value>
<bookmark_value>cell references;ranges intersection</bookmark_value>
</bookmark>
<h1 id="hd_id3156423"><variable id="relativ_absolut_ref"><link href="text/scalc/guide/relativ_absolut_ref.xhp">Addresses and References, Absolute and Relative</link>
</variable></h1>
<h2 id="hd_id191672069640769">Cell references</h2>
<paragraph role="paragraph" id="par_id451672069651941">An individual cell is fully identified by the sheet it belongs, the column identifier (letter) located along the top of the columns and a row identifier (number) found along the left-hand side of the spreadsheet. On spreadsheets read from left to right, the complete reference for the upper left cell of the sheet is <emph>Sheet.A1</emph>.</paragraph>
<h2 id="hd_id211672069771744">Cell ranges</h2>
<paragraph role="paragraph" id="par_id161672070752816">You can reference a set of cells by referencing them in ranges. Ranges can be a block of cells, entire set of columns and entire set of rows. The range A1:B2 is the first four cells in the upper left corner of the sheet. Range A:E contains all the cells of column A, B, C, D and E. Range 2:5 contains all the cells of row 2, 3, 4 and 5.</paragraph>
<embed href="text/scalc/guide/cellreferences.xhp#otherdocref"/>
<embed href="text/scalc/01/04060199.xhp#referenceoperators"/>
<h2 id="hd_id3163712">Relative Addressing</h2>
<paragraph role="paragraph" id="par_id3146119">The cell in column A, row 1 is addressed as A1. You can address a range of adjacent cells by first entering the coordinates of the upper left cell of the area, then a colon followed by the coordinates of the lower right cell. For example, the square formed by the first four cells in the upper left corner is addressed as A1:B2.</paragraph>
<paragraph role="paragraph" id="par_id3154730">By addressing an area in this way, you are making a relative reference to A1:B2. Relative here means that the reference to this area will be adjusted automatically when you copy the formulas.</paragraph>
<h2 id="hd_id3149377">Absolute Addressing</h2>
<paragraph role="paragraph" id="par_id3154943">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.</paragraph>

<section id="abs_rel_types">
    <tip id="par_id3147338">$[officename] can convert the current reference, in which the cursor is positioned in the input line, from relative to absolute and vice versa by pressing <keycode>F4</keycode>. 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)</tip>
</section>

<paragraph role="paragraph" id="par_id3153963">$[officename] 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.</paragraph>
<h2 id="hd_id3154704">When to Use Relative and Absolute References</h2>
<paragraph role="paragraph" id="par_id3147346">What distinguishes a relative reference? Assume you want to calculate in cell E1 the sum of the cells in range A1:B2. The formula to enter into E1 would be: =SUM(A1:B2). If you later decide to insert a new column in front of column A, the elements you want to add would then be in B1:C2 and the formula would be in F1, not in E1. After inserting the new column, you would therefore have to check and correct all formulas in the sheet, and possibly in other sheets.</paragraph>
<paragraph role="paragraph" id="par_id3155335">Fortunately, $[officename] does this work for you. After having inserted a new column A, the formula =SUM(A1:B2) will be automatically updated to =SUM(B1:C2). Row numbers will also be automatically adjusted when a new row 1 is inserted. Absolute and relative references are always adjusted in $[officename] Calc whenever the referenced area is moved. But be careful if you are copying a formula since in that case only the relative references will be adjusted, not the absolute references.</paragraph>
<paragraph role="paragraph" id="par_id3145791">Absolute references are used when a calculation refers to one specific cell in your sheet. If a formula that refers to exactly this cell is copied relatively to a cell below the original cell, the reference will also be moved down if you did not define the cell coordinates as absolute.</paragraph>
<paragraph role="paragraph" id="par_id3147005">Aside from when new rows and columns are inserted, references can also change when an existing formula referring to particular cells is copied to another area of the sheet. Assume you entered the formula =SUM(A1:A9) in row 10. If you want to calculate the sum for the adjacent column to the right, simply copy this formula to the cell to the right. The copy of the formula in column B will be automatically adjusted to =SUM(B1:B9).</paragraph>
<section id="relatedtopics">
<embed href="text/scalc/guide/value_with_name.xhp#value_with_name"/><comment>mw changed link target from "address_byname" to "value_with_name"</comment><embed href="text/scalc/guide/address_auto.xhp#address_auto"/>
</section>
</body>
</helpdocument>