<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fcells_and_ranges</id>
	<title>EN/documentation/basic guide/cells and ranges - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fcells_and_ranges"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/cells_and_ranges&amp;action=history"/>
	<updated>2026-11-11T14:10:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/cells_and_ranges&amp;diff=15958&amp;oldid=prev</id>
		<title>Sancho: Основной текст</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/cells_and_ranges&amp;diff=15958&amp;oldid=prev"/>
		<updated>2011-09-02T18:05:09Z</updated>

		<summary type="html">&lt;p&gt;Основной текст&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Cells and Ranges&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/rows_and_columns&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/formatting_spreadsheet_documents&lt;br /&gt;
|spread=block&lt;br /&gt;
}}&lt;br /&gt;
 &lt;br /&gt;
A spreadsheet consists of a two-dimensional list containing cells. Each cell is defined by its X and Y-position with respect to the top left cell which has the position (0,0).&lt;br /&gt;
&lt;br /&gt;
== Addressing and Editing Individual Cells ==&lt;br /&gt;
&lt;br /&gt;
The following example creates an object that references the top left cell and inserts a text in the cell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object   &lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 0)&lt;br /&gt;
Cell.String = &amp;quot;Test&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to numerical coordinates, each cell in a sheet has a name, for example, the top left cell (0,0) of a spreadsheet is called &amp;lt;tt&amp;gt;A1&amp;lt;/tt&amp;gt;. The letter &amp;lt;tt&amp;gt;A&amp;lt;/tt&amp;gt; stands for the column and the number 1 for the row. It is important that the '''name''' and '''position''' of a cell are not confused because row counting for names begins with 1 but the counting for position begins with 0.&lt;br /&gt;
&lt;br /&gt;
If the position of the cell is fixed, it is more clear to use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object   &lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellRangeByName(&amp;quot;A1&amp;quot;)&lt;br /&gt;
Cell.String = &amp;quot;Test&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code also works with a named cell.&lt;br /&gt;
&lt;br /&gt;
In {{OOo}}, a table cell can be empty or contain text, numbers, or formulas. The cell type is not determined by the content that is saved in the cell, but rather the object property which was used for its entry. Numbers can be inserted and called up with the &amp;lt;tt&amp;gt;Value&amp;lt;/tt&amp;gt; property, text with the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property, and formulas with the &amp;lt;tt&amp;gt;Formula&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object   &lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 0)&lt;br /&gt;
Cell.Value = 100&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 1)&lt;br /&gt;
Cell.String = &amp;quot;Test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 2)&lt;br /&gt;
Cell.Formula = &amp;quot;=A1&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example inserts one number, one text, and one formula in the fields A1 to A3.&lt;br /&gt;
&lt;br /&gt;
{{SO5note|The &amp;lt;tt&amp;gt;Value&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Formula&amp;lt;/tt&amp;gt; properties supersede the old &amp;lt;tt&amp;gt;PutCell&amp;lt;/tt&amp;gt; method of StarOffice 5 for setting the values of a table cell.}}&lt;br /&gt;
&lt;br /&gt;
{{OOo}} treats cell content that is entered using the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property as text, even if the content is a number. Numbers are left-aligned in the cell instead of right-aligned. You should also note the difference between text and numbers when you use formulas:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 0)&lt;br /&gt;
Cell.Value = 100&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 1)&lt;br /&gt;
Cell.String = 1000&lt;br /&gt;
&lt;br /&gt;
Cell = Sheet.getCellByPosition(0, 2)&lt;br /&gt;
Cell.Formula = &amp;quot;=A1+A2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MsgBox Cell.Value &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although cell A1 contains the value 100 and cell A2 contains the value 1000, the A1+A2 formula returns the value 100. This is because the contents of cell A2 were entered as a string and not as a number.&lt;br /&gt;
&lt;br /&gt;
To check if the contents of a cell contains a number or a string, use the &amp;lt;tt&amp;gt;Type&amp;lt;/tt&amp;gt; property:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
Cell = Sheet.getCellByPosition(1,1)&lt;br /&gt;
&lt;br /&gt;
Cell.Value = 1000&lt;br /&gt;
&lt;br /&gt;
Select Case Cell.Type &lt;br /&gt;
Case com.sun.star.table.CellContentType.EMPTY &lt;br /&gt;
   MsgBox &amp;quot;Content: Empty&amp;quot;&lt;br /&gt;
Case com.sun.star.table.CellContentType.VALUE&lt;br /&gt;
   MsgBox &amp;quot;Content: Value&amp;quot;&lt;br /&gt;
Case com.sun.star.table.CellContentType.TEXT&lt;br /&gt;
   MsgBox &amp;quot;Content: Text&amp;quot;&lt;br /&gt;
Case com.sun.star.table.CellContentType.FORMULA&lt;br /&gt;
   MsgBox &amp;quot;Content: Formula&amp;quot;&lt;br /&gt;
End Select&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Cell.Type&amp;lt;/tt&amp;gt; property returns a value for the &amp;lt;idl&amp;gt;com.sun.star.table.CellContentType&amp;lt;/idl&amp;gt; enumeration which identifies the contents type of a cell. The possible values are:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;EMPTY&amp;lt;/tt&amp;gt;:no value&lt;br /&gt;
;&amp;lt;tt&amp;gt;VALUE&amp;lt;/tt&amp;gt;:number&lt;br /&gt;
;&amp;lt;tt&amp;gt;TEXT&amp;lt;/tt&amp;gt;:strings&lt;br /&gt;
;&amp;lt;tt&amp;gt;FORMULA&amp;lt;/tt&amp;gt;:formula&lt;br /&gt;
&lt;br /&gt;
== Inserting, Deleting, Copying and Moving Cells ==&lt;br /&gt;
&lt;br /&gt;
In addition to directly modifying cell content, {{OOo}} Calc also provides an interface that allows you to insert, delete, copy, or merge cells. The interface (&amp;lt;idl&amp;gt;com.sun.star.sheet.XCellRangeMovement&amp;lt;/idl&amp;gt;) is available through the spreadsheet object and provides four methods for modifying cell content.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;insertCell&amp;lt;/tt&amp;gt; method is used to insert cells into a sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
CellRangeAddress.Sheet = 0&lt;br /&gt;
CellRangeAddress.StartColumn = 1&lt;br /&gt;
CellRangeAddress.StartRow = 1&lt;br /&gt;
CellRangeAddress.EndColumn = 2&lt;br /&gt;
CellRangeAddress.EndRow = 2&lt;br /&gt;
&lt;br /&gt;
Sheet.insertCells(CellRangeAddress, com.sun.star.sheet.CellInsertMode.DOWN)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example inserts a cells range that is two rows by two columns in size into the second column and row (each bear the number 1) of the first sheet (number 0) in the spreadsheet. Any existing values in the specified cell range are moved below the range.&lt;br /&gt;
&lt;br /&gt;
To define the cell range that you want to insert, use the &amp;lt;idl&amp;gt;com.sun.star.table.CellRangeAddress&amp;lt;/idl&amp;gt; structure. The following values are included in this structure:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Sheet (short)&amp;lt;/tt&amp;gt;:number of the sheet (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;StartColumn (long)&amp;lt;/tt&amp;gt;:first column in the cell range (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;StartRow (long)&amp;lt;/tt&amp;gt;:first row in the cell range (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;EndColumn (long)&amp;lt;/tt&amp;gt;:final column in the cell range (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;EndRow (long)&amp;lt;/tt&amp;gt;:final row in the cell range (numbering begins with 0).&lt;br /&gt;
&lt;br /&gt;
The completed &amp;lt;tt&amp;gt;CellRangeAddress&amp;lt;/tt&amp;gt; structure must be passed as the first parameter to the &amp;lt;tt&amp;gt;insertCells&amp;lt;/tt&amp;gt; method. The second parameter of &amp;lt;tt&amp;gt;insertCells&amp;lt;/tt&amp;gt; contains a value of the &amp;lt;idl&amp;gt;com.sun.star.sheet.CellInsertMode&amp;lt;/idl&amp;gt; enumeration and defines what is to be done with the values that are located in front of the insert position. The &amp;lt;tt&amp;gt;CellInsertMode&amp;lt;/tt&amp;gt; enumeration recognizes the following values: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;NONE&amp;lt;/tt&amp;gt;:the current values remain in their present position.&lt;br /&gt;
;&amp;lt;tt&amp;gt;DOWN&amp;lt;/tt&amp;gt;:the cells at and under the insert position are moved downwards.&lt;br /&gt;
;&amp;lt;tt&amp;gt;RIGHT&amp;lt;/tt&amp;gt;:the cells at and to the right of the insert position are moved to the right. &lt;br /&gt;
;&amp;lt;tt&amp;gt;ROWS&amp;lt;/tt&amp;gt;:the rows after the insert position are moved downwards.&lt;br /&gt;
;&amp;lt;tt&amp;gt;COLUMNS&amp;lt;/tt&amp;gt;:the columns after the insert position are moved to the right.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;removeRange&amp;lt;/tt&amp;gt; method is the counterpart to the &amp;lt;tt&amp;gt;insertCells&amp;lt;/tt&amp;gt; method. This method deletes the range that is defined in the &amp;lt;tt&amp;gt;CellRangeAddress&amp;lt;/tt&amp;gt; structure from the sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
CellRangeAddress.Sheet = 0&lt;br /&gt;
CellRangeAddress.StartColumn = 1&lt;br /&gt;
CellRangeAddress.StartRow = 1&lt;br /&gt;
CellRangeAddress.EndColumn = 2&lt;br /&gt;
CellRangeAddress.EndRow = 2&lt;br /&gt;
&lt;br /&gt;
Sheet.removeRange(CellRangeAddress, com.sun.star.sheet.CellDeleteMode.UP)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example removes the &amp;lt;tt&amp;gt;B2:C3&amp;lt;/tt&amp;gt; cell range from the sheet and then shifts the underlying cells up by two rows. The type of removal is defined by one of the following values from the &amp;lt;idl&amp;gt;com.sun.star.sheet.CellDeleteMode&amp;lt;/idl&amp;gt; enumeration:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;NONE&amp;lt;/tt&amp;gt;:the current values remain in their current position.&lt;br /&gt;
;&amp;lt;tt&amp;gt;UP&amp;lt;/tt&amp;gt;:the cells at and below the insert position are moved upwards.&lt;br /&gt;
;&amp;lt;tt&amp;gt;LEFT&amp;lt;/tt&amp;gt;:the cells at and to the right of the insert position are moved to the left.&lt;br /&gt;
;&amp;lt;tt&amp;gt;ROWS&amp;lt;/tt&amp;gt;:the rows after the insert position are moved upwards.&lt;br /&gt;
;&amp;lt;tt&amp;gt;COLUMNS&amp;lt;/tt&amp;gt;:the columns after the insert position are moved to the left.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XRangeMovement&amp;lt;/tt&amp;gt; interface provides two additional methods for moving (&amp;lt;tt&amp;gt;moveRange&amp;lt;/tt&amp;gt;) or copying (&amp;lt;tt&amp;gt;copyRange&amp;lt;/tt&amp;gt;) cell ranges. The following example moves the &amp;lt;tt&amp;gt;B2:C3&amp;lt;/tt&amp;gt; range so that the range starts at position &amp;lt;tt&amp;gt;A6&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress&lt;br /&gt;
Dim CellAddress As New com.sun.star.table.CellAddress&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
&lt;br /&gt;
CellRangeAddress.Sheet = 0&lt;br /&gt;
CellRangeAddress.StartColumn = 1&lt;br /&gt;
CellRangeAddress.StartRow = 1&lt;br /&gt;
CellRangeAddress.EndColumn = 2&lt;br /&gt;
CellRangeAddress.EndRow = 2&lt;br /&gt;
&lt;br /&gt;
CellAddress.Sheet = 0&lt;br /&gt;
CellAddress.Column = 0&lt;br /&gt;
CellAddress.Row = 5&lt;br /&gt;
&lt;br /&gt;
Sheet.moveRange(CellAddress, CellRangeAddress)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to the &amp;lt;tt&amp;gt;CellRangeAdress&amp;lt;/tt&amp;gt; structure, the &amp;lt;tt&amp;gt;moveRange&amp;lt;/tt&amp;gt; method expects a &amp;lt;idl&amp;gt;com.sun.star.table.CellAddress&amp;lt;/idl&amp;gt; structure to define the origin of the move's target region. The &amp;lt;tt&amp;gt;CellAddress&amp;lt;/tt&amp;gt; structure provides the following values:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Sheet (short)&amp;lt;/tt&amp;gt;:number of the spreadsheet (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Column (long)&amp;lt;/tt&amp;gt;:number of the addressed column (numbering begins with 0).&lt;br /&gt;
;&amp;lt;tt&amp;gt;Row (long)&amp;lt;/tt&amp;gt;:number of the addressed row (numbering begins with 0).&lt;br /&gt;
&lt;br /&gt;
The cell contents in the target range are always overwritten by the &amp;lt;tt&amp;gt;moveRange&amp;lt;/tt&amp;gt; method. Unlike in the &amp;lt;tt&amp;gt;InsertCells&amp;lt;/tt&amp;gt; method , a parameter for performing automatic moves is not provided in the &amp;lt;tt&amp;gt;moveRange&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;copyRange&amp;lt;/tt&amp;gt; method functions in the same way as the &amp;lt;tt&amp;gt;moveRange&amp;lt;/tt&amp;gt; method, except that &amp;lt;tt&amp;gt;copyRange&amp;lt;/tt&amp;gt; inserts a copy of the cell range instead of moving it.&lt;br /&gt;
&lt;br /&gt;
{{VBAnote|In terms of their function, the {{OOo}} Basic &amp;lt;tt&amp;gt;insertCell&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;removeRange&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;copyRange&amp;lt;/tt&amp;gt; methods are comparable with the VBA &amp;lt;tt&amp;gt;Range.Insert&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Range.Delete&amp;lt;/tt&amp;gt; ,and &amp;lt;tt&amp;gt;Range.Copy&amp;lt;/tt&amp;gt; methods. Whereas in VBA, the methods are applied to the corresponding &amp;lt;tt&amp;gt;Range&amp;lt;/tt&amp;gt; object, in {{OOo}} Basic they are applied to the associated &amp;lt;tt&amp;gt;Sheet&amp;lt;/tt&amp;gt; object.}}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>