10 It Electronic Spreadsheet Notes01-Combined
10 It Electronic Spreadsheet Notes01-Combined
Consolidating data
Data Consolidation allows you to gather together your data from separate worksheets into a master worksheet.
In other words, the Data Consolidation function takes data from a series of worksheets or workbooks and
summaries it into a single worksheet that you can update easily.
3. If the Source data range list contains named ranges, you can select a source cell range to consolidate with
other areas. If the source range is not named, click in the field to the right and either type a reference for
the first source data range or use the mouse to select the range on the sheet. (You may need to move the
Consolidate dialog to reach the required cells.)
4. Click Add. The selected range now appears on the Consolidation ranges list.
5. Select additional ranges and click Add after each selection.
6. Specify where you want to display the result by selecting a target range from the Copy results to box.
If the target range is not named, click in the field next to Copy results to and enter the reference of the
target range or select the range using the mouse or position the cursor in the top left cell of the target range.
7. Select a function from the Function list. The function specifies how the values of the consolidation ranges
are linked. The Sum function is the default setting. Most of the available functions are statistical (such as
AVERAGE, MIN, MAX, STDEV), and the tool is most useful when you are working with the same data over
and over.
8. Optionally click More in the Consolidate dialog to display additional settings.
Select Link to source data to insert the formulas. This generates the results in the target range
instead of the actual results. If you link the data, any values modified in the source range are
automatically updated in the target range. The corresponding cell references in the target range
are inserted in consecutive rows, which are automatically ordered and then hidden from view.
Only the final result, based on the selected function, is displayed.
Under Consolidate by setting, select either Row labels or Column labels, if the cells of the source
data range are not to be consolidated corresponding to the identical position of the cell in the
range, but instead according to a matching row label or column label. To consolidate by row labels
or column labels, the label must be contained in the selected source ranges. The text in the labels
must be identical, so that rows or columns can be accurately matched. If the row or column label
does not match any that exist in the target range, it will be appended as a new row or column.
9. Click OK to consolidate the ranges.
10. If you are continually working with the same range, then you probably want to use Data > Define Range to
give it a name. Define Range option is available under the Data Menu.
The data from the consolidation ranges and target range are saved when you save the worksheet. If you
later open a worksheet in which consolidation has been defined, this data will again be available.
Creating Subtotals
SUBTOTAL is a function listed under the Mathematical category when you use the Function Wizard (Insert >
Function). Because of its usefulness, the function has a graphical interface. It is accessible from Data menu as
shown in Figure 2.3.
SUBTOTAL, totals/adds data arranged in an array-that is, a group of cells with labels for columns and/or rows.
Using the Subtotals dialog, you can select arrays, and then choose a statistical function to apply to them. For
efficiency, you can choose up to three groups of arrays to which to apply a function. When you click OK, Calc
adds subtotals and grand totals to the selected arrays, using the Result and Result2 cell styles for them. Steps to
insert subtotal values into a sheet:
If you use more than one group, then you can also arrange the subtotals according to choices made on the
dialog‘s Options page (Figure 2.5), including ascending and descending order or using one of the predefined
custom sorts defined under Tools menu as Tools Options OpenOffice.org Calc Sort Lists.
Creating Scenarios
Use Scenarios option under Tools menu to enter variable contents-scenarios-in the same cell. To create a
scenario:
1. Select the cells that contain the values that will change between scenarios. To select multiple cells, hold
down the Ctrl key as you click each cell.
2. Choose Tools > Scenarios.
3. On the Create Scenario dialog (Figure 2.6), enter a name for the new scenario. It‘s best to use a name that
clearly identifies the scenario, not the default name as shown in the illustration. This name is displayed in
the Navigator and on the title bar of the scenario on the sheet itself.
4. Optionally add some information to the Comment box. The example shows the default comment. This
information is displayed in the Navigator when you click the Scenarios icon and select the desired scenario.
5. Optionally select or deselect the options in the Settings section. See below for more information about these
options.
6. Click OK to close the dialog. The new scenario is automatically activated. You can create several scenarios
for any given range of cells.
To calculate annual interest (I), create a table with the values for the capital (C), number of years (n), and
interest rate (r). The formula is I = C*n*r.
Let us assume that the interest rate r of 7.5% and the number of years n (1) will remain constant. However, you
want to know how much the investment capital C would have to be modified in order to attain a particular
return I. For this example, calculate how much capital C would be required if you want an annual return of
100,000
or it can be left blank; for number of years n, 1; for interest rate r, 7.5%). Enter the formula to calculate the
interest I in another cell. Instead of C, n, and r use the reference to the cell with the corresponding value. In our
example, this would be = B1*B2*B3.
1. Place the cursor in the formula cell (B4), and choose Tools > Goal Seek.
2. On the Goal Seek dialog, the correct cell is already entered in the Formula cell field.
3. Place the cursor in the Variable cell field. In the sheet, click in the cell that contains the value to be changed,
in this example it is B1.
4. Enter the desired result of the formula in the Target value field. In this example, the value is 15000. The
figure below shows the cells and fields.
5. Click OK. A dialog appears informing you that the Goal Seek was successful. Click Yes to enter the result in
the cell with the variable value. The result is shown below.
Solver deals with equations with multiple unknown variables. It is 68 specifically designed to minimize or
maximize the result according to a set of rules that you define.
Each of these rules sets up whether an argument in the formula should be greater than, lesser than, or equal to
the value you enter. If you want the argument to remain unchanged, you enter a rule that the cell that contains
it should be equal to its current entry. For arguments that you would like to change, you need to add two rules
to define a range of possible values: the limiting conditions. For example, you can set the constraint that one of
the variables or cells must not be bigger than another variable, or not bigger than a given value. You can also
define the constraint that one or more variables must be integers (values without decimals), or binary values
(where only 0 and 1 are allowed). Once you have finished setting up the rules, you can adjust the argument and
the results by clicking the Solve button.
Solver example
Let's say you have
1000?
To find the answer using Solver:
1. Enter labels and data: ● Row labels: Fund X, Fund Y, and total, in cells A2 thru A4.
Column labels: interest earned, amount invested, interest rate, and time period, in cells B1 thru E1.
Interest rates: 8 and 12, in cells D2 and D3.
Time period: 1, in cells E2 and E3.
Total amount invested: 10000, in cell C4.
2. Enter an arbitrary value (0 or leave blank) in cell C2 as amount invested in Fund X.
3. Enter the formulae given below:
In cell C3, enter the formula C4-C2 (total amount - amount invested in Fund X) as the amount
invested in Fund Y.
In cells B2 and B3, enter the formula for calculating the interest earned (see below).
In cell B4, enter the formula B2+B3 as the total interest earned. 69 Figure2.9: Example setup for
solver
4. Choose Tools Solver. The solver dialog opens as shown in Figure 2.10.
5. Click in the Target cell field. In the sheet, click in the cell that contains the target value. In this example it is
cell B4 containing total interest value.
6. Select Value of and enter 1000 in the field next to it. In this example, the target cell value is 1000 because
your target is a total interest earned of $1000. Select Maximum or Minimum if the target cell value needs to
be one of those extremes.
7. Click in the By changing cells field and click on cell C2 in the sheet. In this example, you need to find the
amount invested in Fund X (cell C2).
8. Enter limiting conditions for the variables by selecting the Cell reference, Operator and Value fields. In this
example, the amount invested in Fund X (cell C2) should not be greater than the total amount available (cell
C4) and should not be less than 0.
9. Click OK. A dialog appears informing you that the Solving successfully finished. Click Keep Result to enter
the result in the cell with the variable value. The result is shown below.
Relevant Knowledge
Spreadsheet also allows you to link the cells from various worksheets and from various other spreadsheets to
summarize data from several sources. In this manner, you can create formulas that span different sources and
make calculations using a combination of local and linked information. Multiple sheets help keep information
organized
Identifying sheets
When you open a new spreadsheet, by default, it has a sheet named Sheet1 which is managed using tabs at the
bottom of the spreadsheet, as shown below.
Each method opens the Insert Sheet dialog. Here you can choose to put the new sheet before or after the
selected sheet and how many sheets to insert.
We need 6 sheets, one for each of the 5 accounts and one as a summary sheet so we will add 3 more. We also
want to name each of these sheets for the account they represent: Summary, Checking Account, Savings
Account, Credit Card 1, Credit Card 2, and Car Loan.
We have two choices: insert 3 new sheets and rename all 6 sheets afterwards; or rename the existing sheets,
then insert the three new sheets 1 at a time, renaming each new sheet during the insert step.
To insert sheets and rename afterwards:
1. In the Insert Sheet dialog, choose the position for the new sheets (in this example, we use After current
sheet).
2. Choose New sheet and 3 as the No. of sheets. (Three sheets are already provided by default.) Because you
are inserting more than one sheet, the Name box is not available.
3. Click OK to insert the sheets.
4. For the next steps, go to "Renaming sheets" below.
i. Rename the existing sheets Summary, Checking Account, and Savings Account, as described in “Renaming
sheets” below.
ii. In the Insert Sheet dialog, choose the position for the first new sheet.
iii. Choose New sheet and 1 as the No. of sheets. The Name box is now available.
iv. In the Name box, type a name for this new sheet, for example Credit Card 1.
v. Click OK to insert the sheet.
vi. Repeat steps 1-4 for each new sheet, giving them the names Credit Card 2 and Car Loan.
On the Insert Sheet dialog, you can also add a sheet from a different spreadsheet file (for example, another Calc
or Excel spreadsheet), by choosing the From file option. Click Browse and select the file; a list of the available
sheets appears in the box. Select the sheet to import. If, after you select the file, no sheets appear you probably
selected an invalid file type (not a spreadsheet, for example).
Note: For a shortcut to inserting a sheet from another file, choose Insert > Sheet from file from the menu bar.
The Insert Sheet dialog opens with the From file option preselected, and then the Insert dialog opens on top of
it.
If you prefer, select the Link option to insert the external sheet as a link instead as a copy. This is one of several
ways to include “live” data from another spreadsheet. The links can be updated manually to show the current
contents of the external file; or, depending on the options you have selected in Tools > Options >
OpenOffice.org Calc > General > Updating, whenever the file is opened.
Renaming Worksheets
At the bottom of each worksheet window is a small tab that indicates the name of the worksheets in the
workbook. These names (Sheet1, Sheet2, Sheet3, and so on) are not very descriptive; you might want to rename
your worksheets to reflect what they contain. For instance, if your workbook contains Students Marks in
individual Subject then you may want to rename the worksheets as Subject names such as English, Mathematics
and Social Science etc.
There are three ways you can rename a worksheet, and the only difference between them is the way in which
you start the renaming process. You can do any of the following:
To make the cell reference in cell B3, select the cell and follow these steps.
1. Click on the = icon next to the formula bar. The icons change and an equals sign appears in the formula
bars shown below.
2. Now, click on the sheet tab for the sheet containing the cell to be referenced. In this case, that is the
Checking Account sheet as shown below.
3. Click on cell F3 (where the balance is) in the Checking Account sheet. The phrase ‘Checking Account’.F3
should appear in the formula bar as shown below.
outside any quotes. So, you can fill in the Savings Account cell reference by just typing it in. Assuming that the
balance is in the same cell in the Savings Account sheet, F3, the cell reference should be =’Savings Account’.F3.
You will get a good feel for the format of the reference if you look closely at the formula bar. Based on this
line you can create the reference using the keyboard.
Looking at the figure above, you can see the general format for the reference is =’file:///Path &File
Name’#$SheetName.CellName.
on the Standard toolbar or choose Insert > Hyperlink from the menu bar. To turn existing text into a
On the left hand side, select one of the four types of hyperlinks:
Internet: the hyperlink points to a web address, normally starting with http://
Mail & News: the hyperlink opens an email message that is pre-addressed to a particular recipient.
Document: the hyperlink points to a place in either the current worksheet or another existing
worksheet.
New document: the hyperlink creates a new worksheet.
The top right part of the dialog changes according to the choice made for the hyperlink category from the left
panel. A full description of all the choices, and their interactions, is beyond the scope of this chapter. Here is a
summary of the most common choices used in presentations.
For an Internet hyperlink, choose the type of hyperlink (choose between Web, FTP or Telnet), and enter the
required web address (URL).
For a Mail and News hyperlink, specify whether it is a mail or news link, the receiver address and for email,
Set the value of Frame to determine how the hyperlink will open. This applies to worksheets that open
in a Web browser.
Form specifies if the link is to be presented as text or as a button. The figure below shows a link
formatted as a button.
Text specifies the text that will be visible to the user. If you do not enter anything here, Calc will use
the full URL or path as the link text. Note that if the link is relative and you move the file, this text will
not change, though the target will.
Name is applicable to HTML documents. It specifies text that will be added as a NAME attribute in the
HTML code behind the hyperlink.
1. Open the Calc worksheet where the external data is to be inserted. This is the target worksheet.
2. Select the cell where the upper left-hand cell of the external data is to be inserted.
3. Choose Insert -> Link to External Data.
4. On the External Data dialog, type the URL of the source worksheet or click the [...] button to open a file
selection dialog. Press Enter to get Calc to load the list of available tables.
5. In the Available tables/range list, select the named ranges or tables you want to insert. You can also specify
that the ranges or tables are updated every (number of) seconds.
6. Click OK to close this dialog and insert the linked data.
3. Enter the location of the database file, or click Browse to open a file browser and select the database file.
4. Type a name to use as the registered name for the database and click OK. The database is added to the list
of registered databases. The OK button is enabled only when both fields are filled in.
Relevant Knowledge
In most office settings, there is a shared drive where teams can store common files for everyone to use. This
usually leads to sighting of the message: “The document [file name] is locked for editing by another user. To
open a read-only copy of this document, click“!! This message appears because someone else already has the file
open.
Sometimes however, it is necessary to have multiple people working on a file at the same time. This can be to
either speed up data entry or simply make things easier for collaboration purposes.
Spreadsheet software allows the user to share the workbook and place it in the network location where several
users can access it simultaneously. In this exercise, you will learn how to share a worksheet in OpenOffice Calc.
If the worksheet was not modified and saved by another user since you opened it, the worksheet is
saved.
If the worksheet was modified and saved by another user since you opened it, one of the following
events will occur:
If the changes do not conflict, the worksheet is saved, the dialog below appears, and any cells modified
by the other user are shown with a red border.
If the changes conflict, the Resolve Conflicts dialog is shown. You must decide for each conflict which
version to keep, yours or the other person’s. When all conflicts are resolved, the worksheet is saved.
While you are resolving the conflicts, no other user can save the shared worksheet.
If another user is trying to save the shared worksheet and resolve conflicts, you see a message that the
shared spreadsheet file is locked due to a merge-in in progress. You can choose to cancel the Save
command for now, or retry saving later. When you successfully save a shared spreadsheet, the
worksheet shows the latest version of all changes that got saved by all users.
Note: Most spreadsheets software automatically turns off some features in shared workbooks. This is
to simplify the workbook since multiple people can be working on the file at the same time. For
example, shared workbooks don‘t allow merging cells, conditional formatting, or inserting
pictures/graphs/etc.
Perform the following activity till you are confident:
S.No. Activity
Record Changes
Calc has the feature to track what data was changed, when the change was made, who made the change and in
which cell the change has occurred. If you are the sponsor of a youth baseball team. The coach has submitted a
budget to you for the season and you need to edit the costs and return it to her. You are concerned that if you
just make the changes, then the coach won't see the changes you made. You decide to use Calc with the record
changes feature turned on, so that the coach can easily see the changes you have made.
The figure below shows the budget spreadsheet your coach submitted.
To make these changes, use the record changes feature in Calc. To start recording changes:
A colored border, with a dot in the upper left-hand corner, appears around a cell where changes were
made. Other reviewers then quickly know which cells were edited. A deleted column or row is marked by
a heavy colored bar.
Some changes, for example cell formatting, are not recorded and marked.
To change the color that indicates changes, select Tools > Options > OpenOffice.org Calc > Changes.
Viewing Changes
Calc gives you tremendous control over what changes you see when reviewing a worksheet. To change the
available filters, select Edit > Changes > Show. The following dialog opens.
Using the different settings, you can control which changes appear on screen. You can filter based on:
You can also access the filter control in the Accept or Reject Changes dialog shown below. Click the Filter tab to
get a set of options similar to those shown in the figure above.
Calc automatically adds to any recorded change a comment describing what was changed (for example, Cell B4
changed from ‘9’ to ‘4’). Reviewers and authors can add their comments to explain their changes.
After you have added a comment to a changed cell, you can see it by hovering the mouse pointer over the cell.
The comment also appears in the dialog when you are accepting and rejecting changes.
1. Select the cell with the comment that you want to edit.
2. Select Edit > Changes > Comments.
3. Edit the comment and click OK.
The Comment column by default contains an explanation of the change that was made. If the reviewer added a
comment to the change, it is displayed, followed by the description of the change.
If more than one person has reviewed the worksheet, one reviewer may have modified another reviewer’s
change. If so, the changes are hierarchically arranged with a plus sign for opening up the hierarchy.
On the Filter tab of this dialog (not shown here), you can choose how to filter the list of changes: by date, author,
cell range, or comments containing specific terms. After selecting the filter criteria, switch back to the List tab to
see the results.
Merging Worksheets
Sometimes, multiple reviewers return edited versions of a worksheet at the same time. In this case, it may be
quicker to review all of these changes at once, rather than one review at a time. For this purpose, Calc provides
the feature of merging worksheets. To merge worksheets, all of the edited worksheets need to have recorded
changes in them.
Now all of the changes are combined into one worksheet and you can accept or reject the changes. Changes
from different authors appear in different colors in the worksheet. In this example, all of the changes from
Robert are blue and the changes from Mia are red.
Comparing Documents
When sharing worksheets reviewers may forget to record the changes they make. This is not a problem with
Calc because Calc can find the changes by comparing worksheets. In order to compare worksheets, you need to
have the original worksheet and the one that is edited. To compare them:
1. Open the edited worksheet that you want to compare with the original worksheet.
2. Select Edit > Compare Document.
3. An open worksheet dialog appears. Select the original worksheet and click Insert.
All data that occurs in the edited worksheet but not in the original is identified as inserted.
All data that is in your original worksheet but is not in the edited worksheet is identified as deleted.
All data that is changed, is marked as changed.
Relevant Knowledge
A macro is a saved sequence of commands or keystrokes that are stored for later use. An example of a simple
macro is one that “types” your address. The OpenOffice.org (OOo) macro language is very flexible, allowing
automation of both simple and complex tasks. Macros are especially useful to repeat a task the same way over
and over again.
3. Select cell A3, which contains the number 3, and copy the value to the clipboard.
4. Select the range A1:C3.
5. Use Tools > Macros > Record Macro to start the macro recorder. The Record Macro dialog is displayed
with a stop recording button.
6. Use Edit > Paste Special to open the Paste Special dialog.
7. Set the operation to Multiply and click OK. The cells are now multiplied by 3.
8. Click Stop Recording to stop the macro recorder. The OpenOffice.org Basic Macros dialog opens.
9. Select the current worksheet. For this example, the current Calc worksheet is Untitled 1. Existing
worksheets show a library named Standard. This library is not created until the worksheet is saved, or the
library is needed, so at this point your new worksheet does not contain a library. You can create a new
library to contain the macro, but this is not necessary.
10. Click New Module. If no libraries exist, then the Standard library is automatically created and used. In the
New Module dialog, type a name for the new module or leave the name as Module1.
11. Click OK to create a module named Module1. Select the newly created Module1, enter the macro name
PasteMultiply and click Save.
12. The created macro is saved in Module1 of the Standard library in the Untitled 1 worksheet
Note: Function names are not case sensitive. You can enter =NumberFive() and Calc clearly shows
=NUMBERFIVE().
Save the Calc document, close it, and open it again. Depending on your settings in Tools > Options >
OpenOffice.org > Security > Macro Security, Calc will display one of the warnings shown below. You will need to
click Enable Macros, or Calc will not allow any macros to be run inside the document.
If you choose to disable macros, then when the document loads, Calc can no longer find the function.
When a document is created and saved, it automatically contains a library named Standard. The Standard
library is automatically loaded when the document is opened. No other library is automatically loaded.
Calc does not contain a function named NumberFive(), so it checks all opened and visible macro libraries for
the function. Libraries in OpenOffice.org Macros, My Macros, and the Calc document are checked for an
appropriately named function. The NumberFive() function is stored in the AuthorsCalcMacros library, which is
not automatically loaded when the document is opened.
Use Tools > Macros > Organize Macros > OpenOffice.org Basic to open the OpenOffice.org Basic Macros
dialog shown further down the page. Expand CalcTestMacros and find AuthorsCalcMacros. The icon for a
loaded library is a different color from the icon for a library that is not loaded.
Click the expansion symbol (usually a plus or a triangle) next to AuthorsCalcMacros to load the library. The icon
changes color to indicate that the library is now loaded. Click Close to close the dialog.
Unfortunately, the cells containing =NumberFive() are in error. Calc does not recalculate cells in error unless
you edit them or somehow change them. The usual solution is to store macros used as functions in the Standard
library. If the macro is large or if there are many macros, a stub with the desired name is stored in the Standard
library. The stub macro loads the library containing the implementation and then calls the implementation.
1. Use Tools > Macros > Organize Macros > OpenOffice.org Basic to open the OpenOffice.org Basic Macros
dialog. Select the NumberFive macro and click Edit to open the macro for editing.
TheSum = 0.0
If NOT IsMissing(x) Then
If NOT IsArray(x) Then
If x > 0 Then TheSum =x
Else
For iRow = LBound(x, 1) To UBound (x, 1)
For iCol = LBound(x, 2) To UBound (x, 2)
If x(iRow, iCol) > 0 Then TheSum = TheSum + x(iRow, iCol)
Next
Next
End If
End If
PositiveSum = TheSum
End Function
The macro in Listing 5 demonstrates a couple of important techniques.
1. The argument x is optional. If the argument is not optional and it is called without an argument, OOo prints
a warning message every time the macro is called. If Calc calls the function many times, then the error is
displayed many times.
2. IsMissing checks that an argument was passed before the argument is used.
3. IsArray checks to see if the argument is a single value, or an array. For example, = PositiveSum(7) or =
PositiveSum(A4). In the first case, the number 7 is passed as an argument, and in the second case, the value
of cell A4 is passed to the function.
4. If a range is passed to the function, it is passed as a two-dimensional array of values; for example,
=PositiveSum(A2:B5). LBound and UBound are used to determine the array bounds that are used. Although
the lower bound is one, it is considered safer to use LBound in case it changes in the future.
Note: The macro in Listing 5 is careful and checks to see if the argument is an array or a single argument.
The macro does not verify that each value is numeric. You may be as careful as you desire. The more things
you check, the more robust the macro is, and the slower it runs. Passing one argument is as easy as passing
two: add another argument to the function definition (see Listing 6). When calling a function with two
arguments, separate the arguments with a semicolon; for example, =TestMax(3; -4).
Listing 6. TestMax accepts two arguments and returns the larger of the two.
Function TestMax }(x, y)
If x >= y Then
TestMax = x
Else
TestMax = y
End If
End Function
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)
oCell = oSheet.getCellByPosition (0, 1) ' GetCell A2
TheSum = TheSum + oCell.getValue()
Next
SumCellsAllSheets = TheSum
End Function
Sorting
Sorting data can be automated in Open Office by creating a Macro in Calc. Data can be sorted on a single
column or more than one column. Each time the Macro runs the data gets sorted. Such macros can be written
using code in Open Office. Consider sorting the data in the figure below. First, sort on column B descending and
then column A ascending.