0% found this document useful (0 votes)
21 views31 pages

2-Enter Edit Format Data

Uploaded by

Sudhi glm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views31 pages

2-Enter Edit Format Data

Uploaded by

Sudhi glm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Calc Guide

Chapter 2
Entering, Editing, and
Formatting Data
Copyright
This document is Copyright © 2005–2012 by its contributors as listed below. You may distribute it
and/or modify it under the terms of either the GNU General Public License
(http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution
License (http://creativecommons.org/licenses/by/3.0/), version 3.0 or later.
All trademarks within this guide belong to their legitimate owners.

Contributors
Barbara Duprey
Jean Hollis Weber
John A Smith

Feedback
Please direct any comments or suggestions about this document to:
[email protected]

Acknowledgments
This chapter is based on Chapter 2 of the OpenOffice.org 3.3 Calc Guide. The contributors to that
chapter are:
Peter Kupfer Andy Brown Stephen Buck
Iain Roberts Hazel Russman Barbara M. Tobias
Jean Hollis Weber Jared Kobos

Publication date and software version


Published 3 May 2012. Based on LibreOffice 3.4.6.

Note for Mac users


Some keystrokes and menu items are different on a Mac from those used in Windows and Linux.
The table below gives some common substitutions for the instructions in this chapter. For a more
detailed list, see the application Help.

Windows or Linux Mac equivalent Effect


Tools > Options menu LibreOffice > Preferences Access setup options
selection
Right-click Control+click Opens a context menu
Ctrl (Control) z (Command) Used with other keys
F5 Shift+z+F5 Opens the Navigator
F11 z+T Opens the Styles and Formatting window

Documentation for LibreOffice is available at http://www.libreoffice.org/get-help/documentation


Contents
Copyright.............................................................................................................................. 2
Note for Mac users...............................................................................................................2
Introduction.......................................................................................................................... 5
Entering data using the keyboard...................................................................................... 5
Entering numbers........................................................................................................................ 5
Entering text................................................................................................................................. 5
Entering numbers as text............................................................................................................. 5
Entering dates and times............................................................................................................. 6
Entering special characters.......................................................................................................... 6
Inserting dashes...................................................................................................................... 6
Deactivating automatic changes.................................................................................................. 7
Speeding up data entry....................................................................................................... 7
Using the Fill tool on cells............................................................................................................ 7
Using a fill series..................................................................................................................... 8
Defining a fill series................................................................................................................. 9
Using selection lists................................................................................................................... 10
Sharing content between sheets......................................................................................10
Validating cell contents..................................................................................................... 10
Editing data.........................................................................................................................13
Removing data from a cell......................................................................................................... 13
Replacing all the data in a cell................................................................................................... 13
Changing part of the data in a cell............................................................................................. 13
Formatting data.................................................................................................................. 14
Formatting multiple lines of text................................................................................................. 14
Using automatic wrapping..................................................................................................... 14
Using manual line breaks...................................................................................................... 15
Shrinking text to fit the cell......................................................................................................... 15
Formatting numbers................................................................................................................... 15
Formatting the font..................................................................................................................... 16
Choosing font effects................................................................................................................. 17
Setting cell alignment and orientation........................................................................................ 17
Formatting the cell borders........................................................................................................ 18
Formatting the cell background.................................................................................................. 19
Autoformatting cells and sheets...................................................................................... 19
Defining a new AutoFormat........................................................................................................ 19
Formatting spreadsheets using themes..........................................................................20
Value Highlighting...................................................................................................................... 20
Using conditional formatting............................................................................................ 21
Hiding and showing data.................................................................................................. 22
Outline group controls................................................................................................................ 22

Entering, Editing, and Formatting Data 3


Filtering which cells are visible................................................................................................... 23
Sorting records.................................................................................................................. 26
Finding and replacing in Calc...........................................................................................28
Using the Find toolbar................................................................................................................ 28
Using the Find & Replace dialog................................................................................................ 28
Finding and replacing formulas or values...................................................................................30
Finding and replacing text.......................................................................................................... 30
Finding and replacing cell styles................................................................................................ 30
Using wildcards (regular expressions)....................................................................................... 30

4 Entering, Editing, and Formatting Data


Introduction
You can enter data into Calc in several ways: using the keyboard, the mouse (dragging and
dropping), the Fill tool, and selection lists. Calc also provides the ability to enter information into
multiple sheets of the same document at the same time.
After entering data, you can format and display it in various ways.

Entering data using the keyboard


Most data entry in Calc can be accomplished using the keyboard.

Entering numbers
Click in the cell and type in the number using the number keys on either the main keyboard or the
numeric keypad.
To enter a negative number, either type a minus (–) sign in front of it or enclose it in parentheses
(brackets), like this: (1234).
By default, numbers are right-aligned and negative numbers have a leading minus symbol.

Entering text
Click in the cell and type the text. Text is left-aligned by default.

Entering numbers as text


If a number is entered in the format 01481, Calc will drop the leading 0. (Exception: see Tip below.)
To preserve the leading zero, for example for telephone area codes, type an apostrophe before the
number, like this: '01481.
The data is now treated as text and displayed exactly as entered. Typically, formulas will treat the
entry as a zero and functions will ignore it.

Numbers can have leading zeros and still be regarded as numbers (as opposed to
text) if the cell is formatted appropriately. Right-click on the cell and chose Format
Tip Cells > Numbers. Adjust the Leading zeros setting to add leading zeros to
numbers.

When a plain apostrophe is used to allow a leading 0 to be displayed, it is not


visible in the cell after the Enter key is pressed. If “smart quotes” are used for
apostrophes, the apostrophe remains visible in the cell.
Note
To choose this type of apostrophe, use Tools > AutoCorrect Options >
Localized Options. Select the Replace option for apostrophes to activate this
function. The selection of the apostrophe type affects both Calc and Writer.

Caution
When a number is formatted as text, take care that the cell containing the number
is not used in a formula because Calc will ignore the value.

Entering data using the keyboard 5


Entering dates and times
Select the cell and type the date or time. You can separate the date elements with a slash (/) or a
hyphen (–) or use text such as 10 Oct 03. Calc recognizes a variety of date formats. You can
separate time elements with colons such as 10:43:45.

Entering special characters


A “special” character is one not found on a standard English keyboard. For example, © ¾ æ ç ñ ö
ø ¢ are all special characters. To insert a special character:
1) Place the cursor in your document where you want the character to appear.
2) Click Insert > Special Character to open the Special Characters dialog (Figure 1).
3) Select the characters (from any font or mixture of fonts) you wish to insert, in order; then
click OK. The selected characters are shown in the bottom left of the dialog. As you select
each character, it is shown alone at the bottom right, along with the numerical code for that
character.

Different fonts include different special characters. If you do not find a particular
Note special character you want, try changing the Font selection.

Figure 1: The Special Characters dialog

Inserting dashes
To enter en and em dashes, you can use the Replace dashes option under Tools > AutoCorrect
Options > Options tab. This option replaces two hyphens, under certain conditions, with the
corresponding dash.
In the following table, the A and B represent text consisting of letters A to Z or digits 0 to 9.

6 Entering, Editing, and Formatting Data


Text that you type: Result

A - B (A, space, hyphen, space, B) A – B (A, space, en-dash, space, B)

A -- B (A, space, hyphen, hyphen, space, B) A – B (A, space, en-dash, space, B)

A--B (A, hyphen, hyphen, B) A—B (A, em-dash, B)

A-B (A, hyphen, B) A-B (unchanged)

A -B (A, space, hyphen, B) A -B (unchanged)

A --B (A, space, hyphen, hyphen, B) A –B (A, space, en-dash, B)

Deactivating automatic changes


Calc automatically applies many changes during data input, unless you deactivate those changes.
You can also immediately undo any automatic changes with Ctrl+Z.

AutoCorrect changes
Automatic correction of typing errors, replacement of straight quotation marks by curly (custom)
quotes, and starting cell content with an uppercase (capital) letter are controlled by Tools >
AutoCorrect Options. Go to the Options or Replace tabs to deactivate any of the features that
you do not want. On the Replace tab, you can also delete unwanted word pairs and add new
ones as required.

AutoInput
When you are typing in a cell, Calc automatically suggests matching input found in the same
column. To turn the AutoInput on and off, set or remove the check mark in front of Tools > Cell
Contents > AutoInput.

Automatic date conversion


Calc automatically converts certain entries to dates. To ensure that an entry that looks like a
date is interpreted as text, type an apostrophe at the beginning of the entry. The apostrophe is
not displayed in the cell.

Speeding up data entry


Entering data into a spreadsheet can be very labor-intensive, but Calc provides several tools for
removing some of the drudgery from input.
The most basic ability is to drop and drag the contents of one cell to another with a mouse. Many
people also find AutoInput helpful. Calc also includes several other tools for automating input,
especially of repetitive material. They include the Fill tool, selection lists, and the ability to input
information into multiple sheets of the same document.

Using the Fill tool on cells


At its simplest, the Fill tool is a way to duplicate existing content. Start by selecting the cell to copy,
then drag the mouse in any direction (or hold down the Shift key and click in the last cell you want
to fill), and then choose Edit > Fill and the direction in which you want to copy: Up, Down, Left or
Right.

Speeding up data entry 7


Caution Choices that are not available are grayed out, but you can still choose the
opposite direction from what you intend, which could cause you to overwrite cells
accidentally.

A shortcut way to fill cells is to grab the “handle” in the lower right-hand corner of
the cell and drag it in the direction you want to fill. If the cell contains a number, the
Tip number will fill in series. If the cell contains text, the same text will fill in the
direction you chose.

Figure 2: Using the Fill tool

Using a fill series


A more complex use of the Fill tool is to use a fill series. The default lists are for the full and
abbreviated days of the week and the months of the year, but you can create your own lists as
well.
To add a fill series to a spreadsheet, select the cells to fill, choose Edit > Fill > Series. In the Fill
Series dialog, select AutoFill as the Series type, and enter as the Start value an item from any
defined series. The selected cells then fill in the other items on the list sequentially, repeating from
the top of the list when they reach the end of the list.

Figure 3: Specifying the start of a fill series (result is in Figure 4)

8 Entering, Editing, and Formatting Data


Figure 4: Result of fill series selection
shown in Figure 3

You can also use Edit > Fill > Series to create a one-time fill series for numbers by entering the
start and end values and the increment. For example, if you entered start and end values of 1 and
7 with an increment of 2, you would get the sequence of 1, 3, 5, 7.
In all these cases, the Fill tool creates only a momentary connection between the cells. Once they
are filled, the cells have no further connection with one another.

Defining a fill series


To define your own fill series, go to Tools > Options > LibreOffice Calc > Sort Lists. This dialog
shows the previously-defined series in the Lists box on the left, and the contents of the highlighted
list in the Entries box.

Figure 5: Predefined fill series

Click New. The Entries box is cleared. Type the series for the new list in the Entries box (one entry
per line), and then click Add.

Speeding up data entry 9


Figure 6: Defining a new fill series

Using selection lists


Selection lists are available only for text, and are limited to using only
text that has already been entered in the same column.
To use a selection list, right-click a blank cell and select Selection List
from the context menu. A list box containing all the text, or entries
formatted as text, found in the current column is displayed. The text is
sorted alphabetically and multiple entries are listed only once. Click on
the entry you require.
If you have changed the compatibility setting from Default to
OpenOffice.org legacy in Tools > Options > LibreOffice Calc >
Compatibility, then clicking in an empty cell and pressing Ctrl+D opens
the selection list.

Sharing content between sheets


You might want to enter the same information in the same cell on multiple sheets, for example to
set up standard listings for a group of individuals or organizations. Instead of entering the list on
each sheet individually, you can enter it in all the sheets at once. To do this, select all the sheets
(Edit > Sheet > Select), then enter the information in the current one.

This technique overwrites any information that is already in the cells on the other
Caution
sheets—without any warning. For this reason, when you are finished, be sure to
deselect all the sheets except the one you want to edit. (Ctrl+click on a sheet tab
to select or deselect the sheet.)

Validating cell contents


When creating spreadsheets for other people to use, you may want to make sure they enter data
that is valid or appropriate for the cell. You can also use validation in your own work as a guide to
entering data that is either complex or rarely used.

10 Entering, Editing, and Formatting Data


Fill series and selection lists can handle some types of data, but they are limited to predefined
information. To validate new data entered by a user, select a cell and use Data > Validity to define
the type of contents that can be entered in that cell. For example, a cell might require a date or a
whole number, with no alphabetic characters or decimal points; or a cell may not be left empty.
Depending on how validation is set up, the tool can also define the range of values that can be
entered and provide help messages that explain the content rules you have set up for the cell and
what users should do when they enter invalid content. You can also set the cell to refuse invalid
content, accept it with a warning, or—if you are especially well-organized—start a macro when an
error is entered.
Validation is most useful for cells containing functions. If cells are set to accept invalid content with
a warning, rather than refusing it, you can use Tools > Detective > Mark Invalid Data to find the
cells with invalid data. The Detective function marks any cells containing invalid data with a circle.
Note that a validity rule is considered part of a cell’s format. If you select Format or Delete All from
the Delete Contents window, then it is removed. (Repeating the Detective’s Mark Invalid Data
command removes the invalid data circle, because the data is no longer invalid.) If you want to
copy a validity rule with the rest of the cell, use Edit > Paste Special > Paste Formats or Paste
All.
Figure 7 shows the choices for a typical validity test. Note the Allow blank cells option under the
Allow list.

Figure 7: Typical validity test choices

The validity test options vary with the type of data selected from the Allow list. For example, Figure
8 shows the choices when a cell must contain a cell range.

Validating cell contents 11


Figure 8: Validity choices for a cell range

To provide input help for a cell, use the Input Help page of the Validity dialog (Figure 9). To show
an error message when an invalid value is entered, use the Error Alert page (Figure 10). Be sure to
write something helpful, explaining what a valid entry should contain—not just “Invalid data—try
again” or something similar.

Figure 9: Defining input help for a cell

Figure 10: Defining an error message for a cell with invalid data

12 Entering, Editing, and Formatting Data


Editing data
Editing data is done is in much the same way as entering it. The first step is to select the cell
containing the data to be edited.

Removing data from a cell


Data can be removed (deleted) from a cell in several ways.

Removing data only


The data alone can be removed from a cell without removing any of the formatting of the cell.
Click in the cell to select it, and then press the Delete key. In OpenOffice.org legacy mode,
press the Backspace key.

Removing data and formatting


The data and the formatting can be removed from a cell at the same time. Press the
Backspace key, or if in legacy mode press the Delete key (or right-click and choose Delete
Contents, or use Edit > Delete Contents) to open the Delete Contents dialog (Figure 11).
From this dialog, different aspects of the cell can be deleted. To delete everything in a cell
(contents and format), check Delete all.

Figure 11: Delete Contents dialog

Replacing all the data in a cell


To remove data and insert new data, simply type over the old data. The new data will retain the
original formatting.

Changing part of the data in a cell


Sometimes it is necessary to change the contents of a cell without removing all of the contents, for
example when the phrase “See Dick run” is in a cell and it needs to be changed to “See Dick run
fast.” It is often useful to do this without deleting the old cell contents first.
The process is the similar to the one described above, but you need to place the cursor inside the
cell. You can do this in two ways.

Editing data 13
Using the keyboard
After selecting the appropriate cell, press the F2 key and the cursor is placed at the end of the
cell. Then use the keyboard arrow keys to move the cursor through the text in the cell.

Using the mouse


Using the mouse, either double-click on the appropriate cell (to select it and place the cursor in
it for editing), or single-click to select the cell and then move the mouse pointer up to the input
line and click into it to place the cursor for editing.

Formatting data
The data in Calc can be formatted in several ways. It can either be edited as part of a cell style so
that it is automatically applied, or it can be applied manually to the cell. Some manual formatting
can be applied using toolbar icons. For more control and extra options, select the appropriate cell
or cells range, right-click on it, and select Format Cells. All of the format options are discussed
below.

All the settings discussed in this section can also be set as a part of the cell style.
Note See Chapter 4, Using Styles and Templates, for more information.

Formatting multiple lines of text


Multiple lines of text can be entered into a single cell using automatic wrapping or manual line
breaks. Each method is useful for different situations.

Using automatic wrapping


To set text to wrap at the end of the cell, right-click on the cell and select Format Cells (or choose
Format > Cells from the menu bar, or press Ctrl+1). On the Alignment tab (Figure 12), under
Properties, select Wrap text automatically. The results are shown in Figure 13.

Figure 12: Alignment page of the Format Cells dialog

14 Entering, Editing, and Formatting Data


Figure 13: Automatic text wrap

Using manual line breaks


To insert a manual line break while typing in a cell, press Ctrl+Enter. This method does not work
with the cursor in the input line. When editing text, first double-click the cell, then single-click at the
position where you want the line break.
When a manual line break is entered, the cell width does not change. Figure 14 shows the results
of using two manual line breaks after the first line of text.

Figure 14: Cell with manual line breaks

Shrinking text to fit the cell


The font size of the data in a cell can automatically adjust to fit in a cell. To do this, select the
Shrink to fit cell size option in the Format Cells dialog (Figure 12). Figure 15 shows the results.

Figure 15: Shrinking font size to fit cells

Formatting numbers
Several different number formats can be applied to cells by using icons on the Formatting toolbar.
Select the cell, then click the relevant icon. Some icons may not be visible in a default setup; click
the down-arrow at the end of the Formatting bar and select other icons to display.

Figure 16: Number format icons. Left to right: currency, percentage, date,
exponential, standard, add decimal place, delete decimal place.

Formatting data 15
For more control or to select other number formats, use the Numbers tab (Figure 17) of the Format
Cells dialog.
• Apply any of the data types in the Category list to the data.
• Control the number of decimal places and leading zeros.
• Enter a custom format code.
The Language setting controls the local settings for the different formats such as the date order
and the currency marker.

Figure 17: Format Cells > Numbers

Formatting the font


To quickly choose the font used in a cell, select the cell, then click the arrow next to the Font Name
box on the Formatting toolbar and choose a font from the list.

To choose whether to show the font names in their font or in plain text, go to Tools
> Options > LibreOffice > View and select or deselect the Show preview of fonts
Tip option in the Font Lists section. For more information, see Chapter 14, Setting Up
and Customizing Calc.

To choose the size of the font, click the arrow next to the Font Size box on the Formatting toolbar.
For other formatting, you can use the Bold, Italic, or Underline icons.
To choose a font color, click the arrow next to the Font Color icon to
display a color palette. Click on the required color.
(To define custom colors, use Tools > Options > LibreOffice > Colors.
See Chapter 14, Setting Up and Customizing Calc, for more information.)
To specify the language of the cell (useful because it allows different
languages to exist in the same document and be spell checked
correctly), use the Font tab of the Format Cells dialog. See Chapter 4 for
more information.

16 Entering, Editing, and Formatting Data


Choosing font effects
The Font Effects tab (Figure 18) of the Format Cells dialog offers more font options.
Overlining and underlining
You can choose from a variety of overlining and underlining options (solid lines, dots, short and
long dashes, in various combinations) and the color of the line.
Strikethrough
The strikethrough options include lines, slashes, and Xs.
Relief
The relief options are embossed (raised text), engraved (sunken text), outline, and shadow.

Figure 18: Font Effects page of the Format Cells dialog

Setting cell alignment and orientation


Some of the cell alignment and orientation icons are not shown by default on the Formatting
toolbar. To show them, click on the small arrow at the right-hand end of the toolbar and select them
from the list of icons.

Figure 19: Cell alignment and orientation

Formatting data 17
Some of the alignment and orientation icons are available only if you have Asian or CTL (Complex
Text Layout) languages enabled (in Tools > Options > Language Settings > Languages). If you
select a non-valid icon from the list, it will not appear on the toolbar.
For more control and other choices, use the Alignment tab (Figure 12) of the Format Cells dialog to
set the horizontal and vertical alignment and rotate the text. If you have Asian languages enabled,
then the Text orientation section shows an extra option (labeled Asian layout mode) under the
Vertically stacked option, as shown in Figure 20.

Figure 20: Asian layout mode option


The difference in results between having Asian layout mode on or off is shown in Figure 21.

Figure 21: Types of vertical stacking

Formatting the cell borders


To quickly choose a line style and color for the borders of a cell, click the small arrows next to the
Line Style and Line Color icons on the Formatting toolbar. If the Line Style and Line Color icons
are not displayed in the Formatting toolbar, select the down arrow on the right side of the bar,
then select Visible Buttons. In each case, a palette of choices is displayed.
For more control, including the spacing between the cell borders and the text, use the Borders tab
of the Format Cells dialog. There you can also define a shadow. See Chapter 4 for details.
Unexpected results can occur when formatting cell borders within a range of cells that already
have borders formatted. The newly formatted borders may not be visible on all edges, and may not
print either. To ensure that all the newly formatted borders are visible and will print, you may have
to increase the border width by trial and error to a size sufficiently large to override adjacent cell
border settings. Use the Print Preview control to ensure that borders are visible for printing.

18 Entering, Editing, and Formatting Data


The cell border properties apply to a cell, and can only be changed if you are
editing that cell. For example, if cell C3 has a top border (which would be
Note equivalent visually to a bottom border on C2), that border can only be removed by
selecting C3. It cannot be removed in C2.

Formatting the cell background


To quickly choose a background color for a cell, click the small arrow next to the Background
Color icon on the Formatting toolbar. A palette of color choices, similar to the Font Color palette, is
displayed.
(To define custom colors, use Tools > Options > LibreOffice > Colors. See Chapter 14 for more
information.)
You can also use the Background tab of the Format Cells dialog. See Chapter 4 for details.

Autoformatting cells and sheets


You can use the AutoFormat feature to quickly apply a set of cell formats to a sheet or a selected
cell range.
1) Select the cells that you want to format.
2) Choose Format > AutoFormat from the Menu bar.
3) To select which properties (number format, font, alignment, borders, pattern, autofit width
and height) to include in an AutoFormat, click More. Select or deselect the required
options. Click OK.

Figure 22: Choosing an AutoFormat

Defining a new AutoFormat


You can define a new AutoFormat that is available to all spreadsheets.
To format a sheet:
1) Choose Edit > Select All, or press Ctrl+A.

Autoformatting cells and sheets 19


2) Choose Format > AutoFormat.
3) Click Add.
4) In the Name box of the Add AutoFormat dialog, type a meaningful name for the new format.
5) Click OK to save. The new format is now available in the Format list in the AutoFormat
dialog.

Formatting spreadsheets using themes


Calc comes with a predefined set of formatting themes that you can apply to your spreadsheets.
It is not possible to add themes to Calc, and they cannot be modified. However, you can modify
their styles after you apply them to a spreadsheet.
Before you format a sheet with a theme, you have to apply at least one custom cell style to the
cells on the sheet. You can then change the cell formatting by selecting and applying a theme in
the Theme Selection dialog.
To apply a custom cell style to a cell, you can open the Styles and Formatting window and, in its
lower list box, set the Custom Styles view. A list of the existing custom defined cell styles will be
displayed. Double click a name from the Styles and Formatting window to apply this style to the
selected cells.
To apply a theme to a spreadsheet:
1) Click the Choose Themes icon in the Tools toolbar. If this toolbar is not visible, you can
show it using View > Toolbars > Tools. The Theme Selection dialog appears. This dialog
lists the available themes for the whole spreadsheet and the Styles and Formatting window
lists the custom styles which can be applied to specific cells.

2) In the Theme Selection dialog, select the theme that you want to apply to the spreadsheet.
As soon as you select a theme, some of the properties of the custom styles are applied to
the open spreadsheet and are immediately visible.
3) Click OK. If you wish, you can now go to the Styles and Formatting window to modify
specific styles. These modifications do not change the theme; they only change the
appearance of this specific spreadsheet document.

Value Highlighting
This function displays cell contents in different colors, depending on type.
Select View - Value Highlighting from the Menu bar, or press Ctrl+F8, to toggle the function on or
off.
Text cells are formatted in black, formulas in green, and number cells in blue, no matter how their
display is formatted. If this function is active, colors that you define in the document will not be
displayed. When you deactivate the function, the user-defined colors are displayed again.
The function may be turned on by selecting Tools > Options > LibreOffice Calc > View and
selecting Value Highlighting in the Display section. Selecting here will apply Value Highlighting
each time you open Calc, which you may not want.

20 Entering, Editing, and Formatting Data


Using conditional formatting
You can set up cell formats to change depending on conditions that you specify. For example, in a
table of numbers, you can show all the values above the average in green and all those below the
average in red.

To apply conditional formatting, AutoCalculate must be enabled. Choose Tools >


Note Cell Contents > AutoCalculate.

Conditional formatting requires the use of styles. If you are not familiar with styles, please refer to
Chapter 4. An easy way to set up the required styles is to format a cell the way you want it and
click the New Style from Selection icon in the Styles and Formatting window.
After the styles are set up, here is how to use them.
1) In your spreadsheet, select the cells to which you want to apply conditional formatting.
2) Choose Format > Conditional Formatting from the menu bar.
3) On the Conditional Formatting dialog (Figure 23), enter the conditions. Click OK to save.
The selected cells are now set to apply result-dependent formatting.

Cell value is / Formula is


Specifies whether conditional formatting is dependent on a cell value or on a formula. If you
select cell value is, the Cell Value Condition box is displayed, as shown in the example. Here
you can choose from conditions including less than, greater than, between, and others.

Parameter field
Enter a reference, value, or formula in the parameter field, or in both parameter fields if you
have selected a condition that requires two parameters. You can also enter formulas containing
relative references.

Figure 23: Conditional formatting dialog

Cell style
Choose the cell style to be applied if the specified condition matches. The style must have
been defined previously.
See the Help for more information and examples of use.

Using conditional formatting 21


To apply the same conditional formatting later to other cells:
1) Select one of the cells that has been assigned conditional
formatting.
2) Copy the cell to the clipboard.
3) Select the cells that are to receive this same formatting.
4) Choose Edit > Paste Special.
5) On the Paste Special dialog, in the Selection area, select
only the Formats option. Make sure all other options are
not selected. Click OK.

Hiding and showing data


When elements are hidden, they are neither visible nor printed, but can still be selected for copying
if you select the elements around them. For example, if column B is hidden, it is copied when you
select columns A and C. When you need a hidden element again, you can reverse the process,
and show the element.
To hide or show sheets, rows, and columns, use the options on the Format menu or the right-click
(context) menu. For example, to hide a row, first select the row, and then choose Format > Row >
Hide (or right-click and choose Hide).
To hide or show selected cells, choose Format > Cells from the menu bar (or right-click and
choose Format Cells). On the Format Cells dialog, go to the Cell Protection tab.

Figure 24: Hiding or showing cells

Outline group controls


If you are continually hiding and showing the same cells, you can simplify the process by creating
outline groups, which add a set of controls for hiding and showing the cells in the group, that are
quick to use and always available.
If the contents of cells fall into a regular pattern, such as four cells followed by a total, then you can
use Data > Group and Outline > AutoOutline to have Calc add outline controls based on the
pattern. Otherwise, you can set outline groups manually by selecting the cells for grouping, then

22 Entering, Editing, and Formatting Data


choosing Data > Group and Outline > Group or press F12. On the Group dialog, you can choose
whether to group the selected cells by rows or columns.
When you close the dialog, the outline group controls are visible between either the row or column
headers and the edges of the editing window. The controls resemble the tree-structure of a file-
manager in appearance, and can be hidden by selecting Data > Group and Outline > Hide
Details. They are strictly for online use, and do not print.
The basic outline controls have plus or minus signs at the start of the group to show or hide hidden
cells. However, if outline groups are nested, the controls have numbered buttons for hiding the
different levels.
If you no longer need a group, place the mouse cursor in any cell in it and select Data > Group
and Outline > Ungroup or press Ctrl+F12. To remove all groups on a sheet, select Data > Group
and Outline > Remove.

Figure 25: Outline group controls

Filtering which cells are visible


A filter is a list of conditions that each entry has to meet in order to be displayed. Three filters are
available from the Data > Filter sub-menu.
AutoFilter. This adds a drop-down list to the top row of one or more data columns which lets you
select the rows to be displayed. The list includes every unique entry in the selected cells sorted
into lexical order. See http://sheepsystems.com/bookdog/HelpBook/LexicalOrder.html for an
explanation of lexical order. AutoFilter can now be used on multiple sheets without first defining a
database range.

Hiding and showing data 23


Simple example.

Figure 26: An address list to be filtered

1) Select the data range which we wish to filter: A1 to F15.


2) Select Data > Filter > AutoFilter from the Menu bar.
3) Drop-down list boxes appear at the top of each column.
4) Select the Arrow at the top of the Title column and select all the entries whose title is Mrs
by clicking on this entry in the box ( see Figure 27).

Figure 27: Select Mrs from the Title list


5) The list is filtered to show the rows containing only these entries. The relevant row numbers
are displayed with the other rows hidden. The arrow in the box on the column we chose to
use to filter the data changes color and has an indicator marker in its lower right corner
(Figure 28.

24 Entering, Editing, and Formatting Data


Figure 28: Row numbers of filtered data and altered arrow
6) We can now filter the data by Town, to display only those living in Turpington, by using the
method above. Again the drop-down list arrow displays the indicators to show it has been
used as a filter (Figure 29).

Figure 29: Results of selecting the Town

Filters can be removed individually or all at once.


• To remove the filtering in one go, select the data range:A1:F14. From the Menu bar select
Data > Filter > Remove Filter. The data then returns to its unfiltered state.
• To remove the filtering from any column: click the arrow of the column to be unfiltered and
select All from the list. The result will depend on where in the sequence of applying the
filters, the filter removed was applied.
Standard Filter. This is more complex than AutoFilter. You can set as many as eight arguments as
a filter, using the field name, one of sixteen conditions, and a value, combining them with the
operators AND or OR. Standard filters are mostly useful for numbers, although a few of the
conditional operators, can also be used for text.
To obtain the same results as for our AutoFilter exercise, the Standard Filter could use the settings
in Figure 30. Other Conditions could have been used, for example Contains, in the argument for
the filter, to return the same results.

Figure 30: Standard Filter settings for our addresses


Useful in themselves, Standard Filters take on added value when they are used to further refine
automatic filters.

Hiding and showing data 25


Advanced Filter. This has a structure similar to the Standard Filter. The difference is that the
Advanced Filter arguments are not entered in a dialog. Instead, filters are entered in a blank area
of a sheet, then referenced by the filter dialog in order to apply them.
To filter our data to obtain the same results as our previous examples:
1) Copy the data headings to a blank area of the worksheet.
2) In the cells below, insert the data which is required as the filter.
3) In order to AND the data, enter it on the same row under the relevant pasted headings. (To
OR data, enter it onto different rows under the relevant headings).

Figure 31: The two terms ANDed for the query


4) Select the data range containing the data to be filtered: A1:F15.
5) Select Data > Filter > Advanced Filter.
6) Select the data.
If you select the query range with the mouse, which in our example is A25:F26, then during
the selection, it is outlined in red. On completion, the selected range is indicated by a blue
border around the cells and the Advanced Filter dialog shows the range in absolute terms,
indicated by dollar signs ($) in the references (Figure 32). You can also enter the range
directly into the text box by cell reference. In our example that entry would be; A25:F26.

Figure 32: Filter query argument range


7) Click OK.
The data is filtered, returning the same results as the previous filters.

A maximum of eight rows can be used for the query, including the header row. This
Note equates to the eight arguments of the Standard Filter.

Sorting records
Sorting rearranges the visible cells on the sheet. In Calc, you can sort by up to three criteria, which
are applied one after another. Sorts are handy when you are searching for a particular item, and
become even more powerful after you have filtered data.
In addition, sorting is often useful when you add new information. When a list is long, it is usually
easier to add new information at the bottom of the sheet, rather than inserting rows in the proper
places. After you have added the information, you can sort it to update the sheet.
Highlight the cells to be sorted, then select Data > Sort to open the Sort dialog (Figure
33) or click the Sort Ascending or Sort Descending toolbar buttons. Using the
dialog, you can sort the selected cells using up to three columns, in either ascending
(A-Z, 1-9) or descending (Z-A, 9-1) order.

26 Entering, Editing, and Formatting Data


You can define a custom sort order if the supplied alphanumeric ones do not fit
Tip your requirements. See “Defining a fill series” on page 9 for instructions.

Figure 33: Choosing the criteria and order of sorting

On the Options tab of the Sort dialog (Figure 34), you can choose the following options.

Figure 34: Options for sorting

Case sensitive
If two entries are otherwise identical, one with an upper case letter is placed before one with a
lower case letter in the same position if the sort is descending; if the sort is ascending, then the
entry with an upper case letter is placed after one with a lower case letter in the same position.

Range contains column labels


Does not include the column heading in the sort.

Sorting records 27
Include formats
The formatting of a cell is moved with its contents. If formatting is used to distinguish different
types of cells, then use this option.

Enable Natural Sort


Natural sort is a sort algorithm that sorts string-prefixed numbers based on the value of the
numerical element in each sorted number, instead of the traditional (lexical) way of sorting
them as ordinary strings. For instance, let us assume you have a series of values such as, A1,
A2, A3, A4, A5, A6, ..., A19, A20, A21. When you put these values into a range of cells and run
the sort, it will become A1, A11, A12, A13, ..., A19, A2, A20, A21, A3, A4, A5, ..., A9. While this
sorting behavior may make sense to those who understand the underlying sorting mechanism,
to the rest of the population it seems completely bizarre, if not outright inconvenient. With the
natural sort feature enabled, values such as the ones in the above example get sorted
"properly", which improves the convenience of sorting operations in general.

Copy sort results to


Sets a spreadsheet address to which to copy the sort results. If a range is specified that does
not have the necessary number of cells, then cells are added. If a range contains cells that
already have content, then the sort fails.

Custom sort order


Select the box, then choose from the drop-down list one of the sort orders defined in Tools >
Options > LibreOffice Calc > Sort Lists.

Direction
Sets whether rows or columns are sorted. The default is to sort by columns unless the selected
cells are in a single column.

Finding and replacing in Calc


Calc has two ways to find text within a document: the Find toolbar for fast text searching and the
Find & Replace dialog.

Using the Find toolbar


The Find toolbar is docked by default in the lower left-hand end of the
Calc window. You can hide or show the Find toolbar using View >
Toolbars > Find, or press Ctrl+F. You may undock it and move it to
where you choose.
Type a search term in the Find box, and then click the Find Next (down-arrow) or Find Previous
(up-arrow) button. To find other occurrences of the same term, continue clicking the button.

Using the Find & Replace dialog


To display the Find & Replace dialog (Figure 35), select Edit > Find & Replace from the menu

bar, or select the Find & Replace icon from the Standard Toolbar.

Find & Replace shortcut key.


Note For LibreOffice versions up to and including 3.4.5, press Ctrl+Alt+F. For release
3.4.6. press Ctrl+H.

28 Entering, Editing, and Formatting Data


In spreadsheet documents you can search for text, formulas, and styles. You can navigate from
one occurrence to the next using Find, or you can highlight all matching cells at once using Find
All, then apply another format or replace the cell contents by other content.
Text and numbers in cells may have been entered directly or may be the result of a calculation.
The search method you use depends on the type of data you are searching for.

Cell contents can be formatted in different ways. For example, a number can be
Tip formatted as a currency, to be displayed with a currency symbol. You can see the
currency symbol in the cell, but you cannot search for it.

By default, Calc searches the current sheet. To search through all sheets of the document, click
More Options, then select Search in all sheets option.

Caution Use Replace All with caution; otherwise, you may end up with some highly
embarrassing mistakes. A mistake with Replace All might require a manual, word-
by-word search to fix, if it is not discovered in time to undo it.

Figure 35: Expanded Find & Replace dialog

Finding and replacing in Calc 29


Finding and replacing formulas or values
You can use the Find & Replace dialog to search in formulas or in the displayed values that result
from a calculation.
1) To open the Find & Replace dialog, select Edit > Find & Replace, or use the correct
shortcut key combination for the Calc release you are using (see Find & Replace shortcut
key.)
2) Click More Options to expand the dialog.
3) Select Formulas or Values in the Search in drop-down list.
• Formulas finds parts of the formulas.
• Values finds the results of the calculations.
4) Type the text you want to find in the Search for box.
5) To replace the text with different text, type the new text in the Replace with box.
6) When you have set up your search, click Find. To replace text, click Replace instead.

Finding and replacing text


1) Open the Find & Replace dialog, click More Options to expand the dialog, and select
Values or Notes in the Search in drop-down list.
2) Type the text you want to find in the Search for box.
3) To replace the text with different text, type the new text in the Replace with box.
4) Click Find, Find All, Replace, or Replace All.
When you click Find, Calc selects the next cell that contains your text. You can edit the text, then
click Find again to advance to the next found cell. If you closed the dialog, you can press
Ctrl+Shift+F to find the next cell without opening the dialog.
When you click Find All, Calc selects all cells that contain your entry. Now you can, for example,
apply a cell style to all of them at once.

Finding and replacing cell styles


To quickly change all the cells containing paragraphs of one (unwanted) style to another (preferred)
style:
1) On the expanded Find & Replace dialog, select Search for Styles. The Search for box
contains a list of styles already applied, and the Replace with box contains a list of styles
which can be applied.
2) Select the styles you want to search for and replace.
3) Click Find, Find All, Replace, or Replace All.

Using wildcards (regular expressions)


Wildcards (also known as regular expressions) are combinations of characters that instruct
LibreOffice how to search for something. Regular expressions are very powerful but not very
intuitive. They can save time and effort by combining multiple finds into one.
To use wildcards and regular expressions when searching and replacing:
1) On the Find & Replace dialog, click More Options to see more choices. On this expanded
dialog, select the Regular expressions option.
2) Type the search text, including the wildcards, in the Search for box and the replacement
text (if any) in the Replace with box.
3) Click Find, Find All, Replace, or Replace All (not recommended).

30 Entering, Editing, and Formatting Data


Tip The help files describes many of the regular expressions and their uses.

The following points may be of interest to Calc users:


• In Calc, regular expressions are applied separately to each cell. This means that a search
for r.d will match red in cell A1 but will not match r in cell A2 and d (or ed) in cell A3. (The
regular expression r.d means the system will try to match r followed by any other character
followed by d.)
• When a match is found, the entire cell is highlighted but only the text found will be replaced.
For example, searching for brown will result in highlighting a cell containing redbrown
clay, and choosing nothing in the Replace with box leaves the cell containing red clay.
• If Find is used twice in a row, and the second time the Current selection only box is
activated, then the second search will evaluate the whole of each selected cell, not just the
strings that caused the cells to be selected in the first search. For example, searching for
joh?n, then activating Current selection only and searching for sm.th will find cells
containing Jon Smith and Smythers, Johnathon.
• If a cell contains a hard line break (entered by Ctrl+Enter), it may be found by using the
regular expression \n. For example, if a cell contains red [hard line break] clay then
searching for d\nc and entering nothing in the Replace with box leaves the cell containing
relay.
• The hard line break acts to mark “end of text” (similar to “end of paragraph” in Writer),
found by the regular expression special character $, in addition to the end of text in the cell.
For example, if a cell contains red [hard line break] clay then a search for d$ replacing
with al leaves the cell with real [hard line break] clay. Note that with this syntax the hard
line break is not replaced.
• Using \n in the Replace with box will replace with the literal characters \n, not a hard line
break.
• The Find & Replace dialog has an option to search within formulas, values, or notes. This
option applies to any search, not just one using regular expressions. Searching with the
Formulas option for SUM would find a cell containing the formula =SUM(A1:A6) as well as
a cell containing the simple text SUMMARY.
• Searching for the regular expression ^$ will not find empty cells. This is intentional, to avoid
performance issues when selecting a huge number of cells. Note that empty cells will not
be found even if you are only searching a selection.
• Finding cell contents using the regular expression .+ (or similar) and replacing them with &
effectively re-enters the cell contents without any formatting. This technique can be used to
remove formatting automatically applied by Calc when importing data from the clipboard or
from badly formatted files. For example, to convert text strings consisting of digits into
actual numbers, first format the cells as numbers and then perform the search and replace.
See Chapter 7, Using Formulas and Functions, for the use of regular expressions within formulas.

Finding and replacing in Calc 31

You might also like