Académique Documents
Professionnel Documents
Culture Documents
CHAPTER ONE
WORKING WITH CELLS
1.1 INTRODUCTION:
1.2 CELL REFERENCING
1.2.1 Relative reference
1.2.2 Absolute references use of $
1.2.3 Mixed references
1.3 DEFINED NAME
1.3.1 The Scope of a Name
1.3.2 Syntax Rules for Names:
1.4 To Define Name
1.4.1 To Define a name for a cell or cell range on a worksheet by using Name Box
1.4.2 Define a Name by Using a Selection of Cells in the Worksheet
1.4.3 Define a Name by Using the New Name Dialog Box
1.5 Using Defined Names in Formula:
1.6 To Apply a Defined Name
1.7 Manage Names by Using the Name Manager Dialog Box
1.7.1 Sort names
1.7.2 Filter names
1.7.3 Change a Name
1.7.4 Delete one or more names
CHAPTER TWO
CONDITIONAL FORMATTING IN EXCEL
2.1 About Conditional Formatting
2.2 2-Color Scale
2.3 3-Color Scale
2.4 Data Bar
2.5 Icon Sets
2.6 Conditional Formatting Rules:
2.6.1
Conditional Formatting Rules Manager
2.6.2
Change the format of a rule
2.7 Find Duplicate Data in Excel with Conditional Formatting
2.8 Excel Conditional Formatting for a Date:
2.9 How To Remove Conditional Formatting
CHAPTER THREE
HYPERLINKS & OLE
3.1 Working with Hyperlinks
3.2 To Apply Hyperlink
3.2.1 To Remove a Hyperlink
3.3
Object Linking and Embedding
3.3.1
To Embed
3.3.2
To Link
CHAPTER FOUR
DATA MANAGEMENT
4.0
INTRODUCTION
4.1
Rules Guiding Creation of an Excel Table
4.1.1
Create the Table
4.1.2 To Set a Criteria
4.1.3
How to Create a Drop-Down List in an Excel Cell
4.2
Overview: Using a Data Entry Form
4.2.1
Finding the Data Entry Form Button
4.2.2 To open the Data Entry Form
4.2.3
Entering the Records:
4.3
Using the Form's Data Tools
4.3.1
Searching for Records Using One Field Name
4.3.2
Searching for Records Using Multiple Field Names
4.3.3
4.3.3.1
4.3.3.2
4.4
4.5
4.6
4.7
CHAPTER FIVE
WHAT-IF ANALYSIS
5.1
Using Goal Seek Feature
5.2
Using the Scenario Manager
5.2.1
How to Create a Report from a Scenario
5.3
Data Tables in Excel
CHAPTER SIX
FUNCTIONS
6.1
DATE FUNCTIONS
6.1.1
Excel Date & Time System:
6.1.2
NOW Function:
6.1.3
DATEDIF FUNCTION:
6.1.4
WORKDAY FUNCTION:
6.2
LOGICAL FUNCTIONS
6.2.1
The AND Function
6.2.2
The OR Function
6.3
The IF Function
6.4
Combining the AND and OR Function with the IF Function in Excel
6.5
TEXT FUNCTIONS
6.5.1
String Concatenation
6.5.1.1
LEFT FUNCTION
6.5.1.2
RIGHT FUNCTION:
6.5.1.3
MID FUNCTION:
6.5.1.4
LEN FUNCTION:
6.6.
LOOKUP FUNCTIONS
6.6.1
VLOOKUP
6.6.1.1 The VLOOKUP Dialog Box
6.6.1.2 Excel VLOOKUP Error Messages
6.6.2
FINDING MULTIPLE FIELDS OF INFORMATION WITH THE VLOOKUP FUNCTION
6.6.2.1
Entering the VLOOKUP Array
6.6.3
Creating the VLOOKUP Array Formula
6.6.4
Copying the VLOOKUP Array Formula
6.6.5
Retrieving Data with the VLOOKUP Array Formula
6.6.6
HLOOKUP
6.8
TROUBLESHOOTING FUNCTIONS
CHAPTER SEVEN
MACROS
7.1
Adding the Developer Tab
7.2
Adding a Worksheet Title
7.3
Recording a Macro
7.4
To Run A Macro You Have Recorded:
CHAPTER EIGHT
TEMPLATE & SECURITY & WATERMARK
8.1
Security and Templates
8.2
Working with Templates
8.3
Putting a Watermark on an Excel Document
CHAPTER ONE
1.1 INTRODUCTION:
Microsoft Excel is data sensitive, that is to say Excel distinguishes between numbers, text, currency, dates,
etc, that you enter into it. The reason for this is that Excel will want to know how to process the data you
enter, as different data types may require different processing. Consider, for example, the following
entries made into an Excel worksheet:
Figure 1.1
Of the three columns in Figure 1.1 above, the S/No and Phone No columns are nominal i.e. no
mathematical operation can be performed on them, while only the Cost column are numbers.
1.2 CELL REFERENCING
Cell reference refers to a cell or a range of cells on a worksheet and is used in Excel formulas. There are
two major distinctions:
1.2.1 Relative reference: is based on the relative position of the cell that contains the formula. If the
position of the cell that contains a formula changes, the reference also changes. The copied formula across
rows or down columns, would automatically adjusts. For example, in the worksheet below, if you copy or
fill a relative reference in cell D2 to cell D3, it automatically adjusts from = SUM (A2:B2) to = SUM (A3:B3).
Also, from figure 1.2.1 above, you will notice that Division by 0.5 in Column E3:E7 gives #DIV/0! an error
message because of division by zero occurrence. This is because the formula =C2*D2 was copied or filled
using relative reference.
To correct this error, dollar ($) must precede the reference C2 as $C$2 to make it absolute reference, see
next section 1.2.2.
1.2.2 Absolute references use $: Example $A$1. The dollar sign in Absolute Reference holds the cell
position to be static. In absolute reference, if you copy or fill an absolute reference in cell E2 to cell E3, the
absolute cell C2 stays the same in both cells for the formulas: =D2/$C$2 and D3/$C$2. The value 0.5 is
fixed for all the cells in the range, D2:D7, for the multiplication operation.
1.2.3 Mixed references: A mixed reference has either an absolute column and relative row, or absolute
row and relative column. An absolute column reference takes the form $A1, $B1, while an absolute row
reference takes the form A$1, B$1, and so on. If the position of the cell that contains the formula changes,
the relative reference is changed but the absolute reference does not change. For example, if you copy or
fill a mixed reference from cell C2 to C3, it adjusts from =$A2/B$2 to =$A3/B$2
If you have defined a name for a range, such as Budget_FY08, and its scope is Sheet1, that name,
if not qualified, is reChainnized only in Sheet1, but not in other sheets. To use a local worksheet
name in another worksheet, you have to qualify it by preceding it with the worksheet name and
the big bang (!). For example:
Sheet1! Budget_FY08
The Worksheet
2.
If you have defined a name, such as Sales_Dept_Goals, and its scope is the workbook, that name is
reChainnized for all worksheets in that workbook, but not for any other workbook.
1.4
To Define Name
You can define a name by using the:
Name box on the formula bar: This is best used for creating a workbook level name for a
selected range.
Existing row and column labels of a selection of cells: You can use the Create from
Selection command to conveniently create names from existing row and column labels by
using a selection of cells in the worksheet.
New Name dialog box: This is best used when you want more flexibility in creating names,
such as specifying a local worksheet level scope or creating a name comment.
1.4.1 To Define a name for a cell or cell range on a worksheet by using Name Box
1. Select the cell, range of cells, or nonadjacent selections that you want to name.
2. Click the Name box at the left end of the formula bar
3. Type the name that you want to use to refer to your selection.
4. Press ENTER.
1.4.2 Define a Name by Using a Selection of Cells in the Worksheet
You can convert existing row and column labels to names.
1. Select the range that you want to name, including the row or column labels.
2. On the Formulas tab, in the Defined Names group, click Create from Selection.
3. In the Create Names from Selection dialog box, designate the location that contains the labels by
selecting the Top row, Left column, Bottom row, or Right column check box.
Note: A name created by using this procedure refers only to the cells that
contain values and does not include the existing row and column labels.
1.4.3 Define a Name by Using the New Name Dialog Box
Enter the data into appropriate cells as shown in figure 1.4.3 below.
Figure 1.4.3
1. On the Formulas tab, in the Defined Names group, click Define Name. The New Name dialog box
is displayed. See figure 1.43a below.
2. In the New Name dialog box, in the Name box, type the name that you want to use for your
reference. Type JANContr
3. To specify the scope of the name, in the Scope drop-down list box, select Workbook.
4. In the Comment box, enter a descriptive comment up to 255 characters. This is optional.
5. In the Refers to box, the current selection is entered by default. To enter other cell references as
an argument, click the Collapse Dialog
(which temporarily shrinks the dialog box), select the
cells on the worksheet, and then click select B2 to B5
6. Click the expand Expand Dialog icon
to open up the New Name Dialog box again
7. Repeat steps 2 to 6 to name the next two columns i.e. FEBContr, MARContr respectively
8. To finish and return to the worksheet, click OK.
i.
ii.
In the formula instead of using the cell references, the defined name, JANContr, for the range has
been used.
Instead of typing the full formula in step 2 just type the equality sign, then sum( now locate Use
in Formula command in the Defined Names group of the Formula tab, clicking it drops down a
menu, from the menu select the defined name you wish to use. Excel places it in the formula you
are typing, you can then type ), to complete the formula.
Exercise: Repeat the preceding steps for FEBContr and MARContr, in columns C6 and D6. Use the defined
names to get the grand total in cell E6.
=SUM(JANContr)
1.6
10
Names Scoped To
Workbook
Display only those names with values that contain errors (such as #REF,
#VALUE, or #NAME).
Display only those names with values that do not contain errors.
Defined Names
Table Names
NOTE
, or press ESC.
, or press ENTER.
The Close button only closes the Name Manager Dialog box.
To select more than one name in a contiguous group, click and drag the names, or press
SHIFT and click the mouse button for each name in the group.
To select more than one name in a noncontiguous group, press CTRL and click the mouse
button for each name in the group.
4. Click Delete. You can also press the DELETE key.
5. Click OK to confirm the deletion.
12
CHAPTER TWO
2.1
Conditional formatting can call attention to potential problem areas by highlighting some sensitive
information based on given criteria. For example, you could apply conditional formatting on a range of
cells that contain sales totals; specifying that if any drops below a given amount, the format of the cell
should change and stand out from other cells.
When creating a new formatting rule, several options are available for how you want the formatting to
appear. The following list covers the broad categories for these options, but there are also several
subcategories within each one.
1. Under the Home tab, in the Styles group, click on Conditional Formatting icon to open the drop
down menu.
2.2
2-Color Scale
This option allows you to pick two colors, assigning one to the highest value in a selection and the other
to the lowest. Values that fall within the minimum and maximum will be assigned a color that is
somewhere between these two original choices. For example in a 2-color, green and red color scale,
you can specify that higher value cells have a more green color and lower value cells have a more red
color.
Two-Color Scale
1. Select the relevant cells
2. On the Home tab, Styles group, click the arrow next to Conditional formatting and then click
Color Scales
3. Select a two-color scale.
13
2.3
3-Color Scale
Similar to the 2-Color Scale, this option allows you to pick one additional color that will be
associated with the midpoint of your data range.
Three-Color Scale
1. Select the relevant cells
2. On the Home tab, Styles group, click the arrow next to Conditional formatting and then click
Color Scales
3. Select a three-color scale. The top color represents higher values, the middle colors represent
values about the centre and the bottom color represents the lower values.
2.4
Data Bar
Rather than alter the color of an entire cell, the Data Bar option can be chosen if you want to show how
each particular value in your list compares to the rest of the collection.
Format Cells Using Data Bars
Data bars help you see the value of a cell relative to other cells. The length of the data bar
represents the value in the cell. A longer bar represents a higher value (higher sales, higher
production, etc.) and a shorter bar represents a lower value (lower sales, lower production, etc.)
1. Select the relevant cells
2. On the Home tab, Styles group, click the arrow next to Conditional formatting and then click
Data Bars
3. Select a Data Bar icon.
2.5
Icon Sets
With this tool, you can choose a set of graphics and have your formatting rule apply a different icon to
each value in your list based on the group to which the value belongs. For example, you may choose an
Icon Set with four images, and break your data up into quarters.
Format Cells Using an Icon set
The icon sets help you classify data into three to five categories based on threshold values. For
example in the three arrows icon set, the green up represents higher values, the sideways yellow
reps the middle values and the red down arrow reps the lower values.
1. Select the relevant cells
2. On the Home tab, Styles group, click the arrow next to Conditional formatting then click Icon set
3. Select an icon set.
Note: While it is possible to edit the formatting that is applied with conditional formatting, it is not
possible to edit the date options using the Manage Rules option in the Conditional Formatting drop
down list.
2.6
Conditional Formatting Rules:
In previous versions of Excel, you could have a maximum of three conditional formats. There is no such
limit in Office Excel 2010; you may have as many conditional formats as you like.
When you select which kind of condition to create, Office Excel 2010 displays a dialog box that contains
fields and controls you can use to define your rule. To display all your rules, under the Home tab, in the
14
Styles group, click Conditional Formatting. From the menu that appears, click Manage Rules to display
the Conditional Formatting Rules Manager dialog box.
2.7
The same steps can be followed to use conditional formatting to highlight duplicate data records in an
Excel database, as well as duplicate formulas, dates, or other values in your data range.
2.8
4. Choose Highlight Cell Rules > A Date Occurring... to open the conditional formatting dialog box.
5. Click on the down arrow of the date options drop down menu (left side) to open the list.
6. Select In the last 7 days from the list.
7. Click on the down arrow of the format options drop down menu (right side) to open the list.
8. Select Light Red Fill with Dark Red Text from the list.
9. Click OK to accept the changes and close the dialog box.
10. Type yesterday's date in cell C1 and press the ENTER key on the keyboard.
11. Cell C1 should be formatted with a light red background color and dark red text since yesterday's
date occurred within the last seven days.
2.9
How To Remove Conditional Formatting
Step 1: If you only want the formatting removed from a certain collection of cells, a table, or a pivot
table, select that area on the spreadsheet. Otherwise, if you want the formatting removed from
the entire worksheet, dont worry about selecting anything just continue with the next step;
Step 2: From the Home tab, click on the Conditional Formatting icon in the Styles section.
Step 3: Select Clear Rules and then make an additional selection based on which item spreadsheet,
selected cells, table, or pivot table the conditional formatting should be removed from.
After making this selection, the formatting will disappear. However, you can always use the Undo button
to get it back if you find that you made a mistake.
17
CHAPTER THREE
TIP: To select a cell that has a hyperlink in it without going to the hyperlink destination, click the cell and
hold the mouse button until the pointer becomes a cross, and then release the mouse button.
3.2.1 To Remove a Hyperlink
1. Using the tip given above, make the cell containing the hyperlink the active cell.
2. From the Insert tab of the Ribbon, in the Link group click Hyperlink. The Insert Hyperlink dialog box
is displayed.
3. Click the Remove Link button.
4. Click OK.
18
3.3
Object Linking and Embedding
Object Linking and Embedding (or OLE for short) is a technique used to insert data from one application
to another. We will create a simple spreadsheet to illustrate the process, and place it in to Word document.
When the Excel spreadsheet is edited, the Word version updates itself automatically.
If you do not want the data manipulation in Excel to update in Word, it is called Embedding; but if you do
want the data in Word to be updated, it is called Linking.
3.3.1 To Embed
Enter the data given in the figure below into an Excel spreadsheet, and then do the following:
1.
2.
3.
4.
5.
6.
7.
8.
6.
Go to the Excel spreadsheet and make some changes then come and view the effect in your MS Word.
Word 2010 has successfully linked the data from Excel 2010. This is called Linking.
You can also link or embed things like Charts or Pivot Tables into Word.
20
CHAPTER FOUR
DATA MANAGEMENT
4.0
INTRODUCTION
This section covers how to create a database in Excel as well as a number of Excel's data tools. The tools
include using a form to simplify data entry, sorting and filtering data, removing duplicate records, and
creating drop down lists.
There are many different types of databases available such as Microsoft Access Databases, Oracle
Databases, MySQL databases and so on; but Microsoft Excel has a form of a database known as database
table; it is a flat file.
To look for specific data within a Microsoft Excel Database or Excel Table we do not use the common
database language of SQL, we use specially written functions written by you and known as criteria.
4.1
Rules Guiding Creation of an Excel Table
To create an excel database we must be guided by some rules:
You must maintain one excel database per worksheet else you get yourself into lots of trouble. If
you need to have multiple excel databases within your workbook simply put each excel database
onto a separate worksheet.
The first row of your database table must contain the field names (or header labels) of the list
and the names must be unique.
The next issue you need to be concerned with is identifying the field names; that is, they should
be of different data types, format, pattern etc to the rest of the database in your list. It is advised
to format the field names in bold to satisfy this requirement.
Around the row and columns of the fields and data there must be a blank row and column. What
this means is that you can still have a heading at the top of the fields, but there must be a blank
row between the heading and the fields as well as along the last column as well. The blank row
rule also applies to the bottom of the list as well.
When you are entering data into your list, every cell in every record must contain some value
even if it is simply blank (a blank value is still considered a value) and each record must contain
the same number of fields. If there is no specific data for a field you simply leave it blank and
move to the next field.
Ensure that when you are entering data into a field that you do not have spaces before the text
or at the end of the text in the field. This can affect the sorting and give funny results.
Upper case and low case characters in the field do not affect the searches or sort orders unless
you specifically tell the Microsoft Excel application it is an issue.
You can also use formulas if required. Formulas can refer to cells within the Excel Database table.
You can edit and format the cells just like any other spreadsheet however the issue you must
consider as a priority is that the field names must have a different format to the rest of the data
in the database table.
4.1.1 Create the Table
Once the data has been entered, it can be converted into a table. To do so:
1. Select the data range to make it active
2. Click on the Home tab.
3. Click on the Format as Table option to open the drop down menu.
21
4.
5.
6.
7.
Choose the blue Table Style Medium 9 option to open the Format as Table dialog box.
While the dialog box is open, the selected range will be surrounded by the marching ants.
If the marching ants surround the correct range of cells, click Ok in the Format as Table dialog box.
If the marching ants do not surround the correct range of cells, drag select the correct range in the
spreadsheet and then click Ok in the Format as Table dialog box.
8. The table should have the drop down arrows added beside each field name and the table rows
should be formatted in alternating light and dark blue.
4.1.2 To Set a Criteria
After setting up your table guided by these rules, you are now ready to interrogate or query the table by
applying criteria.
The easiest way that you can do this is by using the Form dialog box. To get into the Excel Database form
choose Data menu and then choose Form from the drop down menu.
From the Excel Database Form you can simply choose the Criteria button, type the criteria you have for
your data and choose the Find Next button and it will take you to the first record that satisfies the
criteria you are searching for.
4.1.3 How to Create a Drop-Down List in an Excel Cell
1. Select the active cell (s) Click on the Data tab.
2. Click on the Data Validation option to open the menu.
3. Click on the Data Validation in the menu to bring up the dialog box.
4. Click on Settings tab in the dialog box.
5. From the Allow menu choose List.
6. Click on the Source line in the dialog box.
7. Select the desired cells in the spreadsheet. Click OK.
8. A down arrow should appear next to the selected cell (s).
9. When you click on the arrow the drop down list should open to display the options.
4.2
Overview: Using a Data Entry Form
Using Excel's built in data entry form; you can enter data into the Excel database. Forms allow you to:
start a new database table or to add new records to an existing one
scroll through data records one at a time
search for records containing specific information
edit or delete individual records if necessary
4.2.1 Finding the Data Entry Form Button
Microsoft chose not to include the Form button on the ribbon. Therefore the first step to using the data
entry form is to add the Form button to the Quick Access Toolbar so that it can be used. Proceed as follows:
Provide the column headings to be used in your database. You can include up to 32 field names in
the form.
Click on the Form button, and Excel will do the rest
It is a one-time operation. Once added, the Form button remains available on the Quick Access Toolbar.
22
4.3
Using the Form's Data Tools
A major problem with a database is maintaining the integrity of the data as the file grows in size. This
requires:
Fixing data errors or updating individual records and
Deleting obsolete or duplicate records.
The data entry form contains several tools along the right hand side that makes it easy to find and
correct or delete records from the database.
These tools are:
1. The Find Prev and Find Next buttons - these allow you to scroll forward and back through the
database one record at a time.
2. The Delete button - this is used to delete records from the database.
3. The Restore button - This button can be used to undo changes to a record that is being edited.
Occasionally, we make the wrong changes to a record or even edit the wrong record all together.
If so, the restore button can be used to undo those changes.
Note: the restore button only works as long as a record is present in the form. As soon as you
access another record or close the form, the restore button becomes inactive.
4. The Criteria button allows you to search the database for records based on specific criteria, such
as name, age, or program
24
ation
4.4
cell
You can restrict what goes in to a cell on your spreadsheet, and display an error message for your users.
This can be done with the Comments column. When a user enters too much text, you can let him know
by displaying a suitable error message. Do this:
When you select Text Length from the list, three new areas appear:
Select Between for Data list box, type 0 for Minimum and 25 for Maximum.
To add an error message, click the Error Alert tab at the top of the Data Validation dialogue box:
25
What we are doing is restricting the amount of text a user can input into any one cell on the Comments
column, to not more than 25 characters.
Now click inside the error message field and type some text for the main body of your error message.
This will tell the user what he or she did wrong:
26
4.5
FILTER
Filter displays only the rows that meet criteria that you specify and hides the others.
After you filter data, you can copy, find, edit, format, chart, and print the subset of filtered data without
rearranging or moving it. You may also filter by more than one column.
Filters are additive, which means that each additional filter is based on the current filter and further
reduces the subset of data.
Note: When you use the Find dialog box to search filtered data, only the data that is displayed is
searched; data that is not displayed is not searched. To search all the data, clear all filters.
4.5.1 The Three Types of Filters
Using AutoFilter, you can filter by:
List of values,
Format, or
Criteria.
Each of these filter types is mutually exclusive for each range of cells or column table. For example,
1. You can filter by cell color or by a list of numbers, but not by both.
2. You can filter by icon or by a custom filter, but not by both.
A drop-down arrow
means that filtering is enabled but not applied.
When you hover over the heading of a column with filtering enabled but not applied, a screen tip
displays "(Showing All)".
A Filter button
means that a filter is applied.
When you hover over the heading of a filtered column, a screen tip displays the filter applied to
that column, such as "Equals a red cell color" or "Larger than 150".
27
The list of text values can be up to 10,000. If the list is large, clear (Select All) at the top, and then
select the specific text values to filter by.
TO FIND
Any single character
For example, sm?th finds "smith" and "smyth"
* (asterisk)
Any number of characters
For example, *east finds "Northeast" and "Southeast"
~ (tilde) followed by ?, *, A question mark, asterisk, or tilde
or ~
For example, fy06~? finds "fy06?"
3. Optionally, filter by one more criteria.
How to add one more criteria
1. Do one of the following:
a. To filter the table column or selection so that both criteria must be true, select And.
b. To filter the table column or selection so that either or both criteria can be true, select Or.
2. In the second entry, select a comparison operator, and then in the box on the right, enter text or
select a text value from the list.
4. To reapply a filter after you change the data, click a cell in the range or table, then on the Data tab,
in the Sort & Filter group, click Reapply.
28
29
31
4.6
PIVOT TABLE
An Excel pivot table is a versatile reporting tool that makes it easy to extract information from a large
table of data without the use of formulas. A pivot table is extremely user friendly in that by moving, or
pivoting, fields of data from one location to another using drag and drop we can look at the same data in
a number of different ways.
4.6.1 Entering Data into a Pivot Table
The first step in creating a pivot table is to enter the data into the worksheet. When doing so, keep the
following points in mind:
At least three columns of data are needed to create a pivot table.
It is important to enter data correctly. Errors, caused by incorrect data entry, are the source of
many problems related to data management.
Leave no blank rows or columns in between. This includes NOT leaving a blank row between the
column headings and the first row of data see example below.
4.6.2
1.
2.
3.
4.
5.
6.
7.
8.
32
A blank pivot table should appear on the worksheet with the top left corner of the pivot table in cell D16.
The Pivot Table Field List panel should open on the right hand side of the Excel window. At the top of the
Pivot Table Field List panel are the field names (column headings) from our data table. The data areas at
the bottom of the panel are linked to the pivot table.
33
34
3. Click on the down arrow next to the Region heading in the Pivot Table to open the filter's drop down
list.
4. Click twice on the check box next to the Select All option to first add and then remove the check marks
from all the boxes in this list.
5. Click on the check box next to the West option to add a check mark to this box. Click OK.
The Pivot Table should now show the total sales for only those sales reps that work in the West region.
4.7
CONSOLIDATION
You can summarize data from one or more sources by consolidating it into a table. The source areas can
be on the same worksheet as the consolidation table, on different sheets in the same workbook, or in
different workbooks. When you consolidate the source data, you apply a summary function, such as the
SUM() function, to create the summary data. There are three ways to consolidate data:
1. Consolidation by category
2. Consolidation by position
3. Consolidation by PivotTable report.
Consolidation by position: When the data in the source areas is arranged in the same order and uses the
same labels. Use this method to consolidate data from a series of worksheets, such as departmental
budget worksheets that have been created from the same template.
Consolidation by category: When the data in the source areas is not arranged in the same order but uses
the same labels. Use this method to consolidate data from a series of worksheets that have different
layouts but have the same data labels.
You can create a PivotTable report from multiple consolidation ranges. This method is similar to
consolidating by category, but it offers more flexibility to reorganize the categories. The use of PivotTables
will be better covered in the section that deals with Data Management, Pivot Tables.
4.7.1
How to Consolidate Data by Position
To consolidate data by position, follow these steps:
1. Data in Sheet1:
2. Data in Sheet2:
35
Click the upper-left cell of the destination area for the consolidated data. In this example, click cell A1 on
Sheet2.
2. On the Data tab, click Consolidate located in the Data Tools group. The Consolidate dialog box is
displayed.
3. In the Function list, select the summary function that you want Microsoft Excel to use to
consolidate the data. In this example, use Sum.
4. In the Reference box do one of these:
a. Type each source area you want to
consolidate, in this example, type the
first area, Sheet1!$A$1:$C$6.
OR
b. Return to sheet1 and select the range
A1-C6.
5. Then click Add.
6. Repeat steps 4 and 5 for the entire source
areas that you want to consolidate.
7. Under Use labels in, select the Top row check
box and the Left column check box (in this
example, there are labels both on the first
row and also in the left column).
Figure 4.7.1b Consolidate Dialog box
8. Click OK.
10. Under Use labels in, click to select the Left column check box (in this example, there are labels in the
left column). Click OK.
NOTE:
If you want Microsoft Excel to update your consolidation table automatically when the source data
changes, select the Create links to source data check box.
You cannot create links when source and destination areas are on the same sheet.
37
CHAPTER FIVE
WHAT-IF ANALYSIS
5.1
Using Goal Seek Feature
Goal Seek feature allows you to alter the data used in a formula in order to find out what the results will
be. The different results can then be compared to find out which one best suites your requirements.
Example 1: Goal Seek:
This example first uses the PMT function to calculate the monthly payments for a loan; then it uses Goal
Seek to lower the monthly payment by altering the loan period.
1. Click on cell B5, type the formula: = PMT (B2/12,
B3, -B4) and press the ENTER key. The value
4,349.88 should appear in cell B5 as the current
monthly payment for the loan.
Altering the monthly payment using Goal Seek:
We would like to pay 3,000 every month (not
4,349.88); and we also want to know the number of
monthly installments and the percentage interest that
would translate to.
2. Under Data tab choose What-If Analysis from the ribbon to open the drop down list.
3. Click on Goal Seek... to bring up the Goal Seek dialog box.
4. Click on the Set cell: line.
5. Click on the T0 value: line, type 3000
6. Click on the By changing cell: line, then click on cell B3 since we want to change the monthly
payment by altering the total number of payments to be made. Click OK.
7. At this point, Goal Seek should begin searching for a solution. If it finds one, the Goal Seek
dialog box will inform you that a solution has been found.
8. In this case, the solution is to change the number of payments in cell B3 to 95.25.
9. To accept this solution, click OK in the Goal Seek dialog box and Goal Seek will alter the data in
cell B3.
10. To find a different solution, click Cancel in the Goal Seek dialog box. Goal Seek returns the
value in cell B3 to 60. You are now ready to run Goal Seek again.
Example 2 Goal Seek
Your business currently has a modest profit of N25,000. Then you set yourself a new profit Goal of
N45,000. At the moment, you are selling 1000 items at N25 each. You still want to sell same quantity of
1,000 at a different price for the new target profit of N45,000. The question is, what should the new
price be?
38
Solution:
Create the spreadsheet (A1:D4) below. Please ensure that cells A4 and E4 are formulas =B3*B3 and
E2*E3 respectively because Goal Seek requires formulas in the two fields.
Follow the steps 2 & 3 above
to get the Goal Seek
dialogue box.
Enter E3 in the By
changing cell box.
Goal Seek Application
Goal Seek will return the Goal Seek Status dialog box as shown above. In our example, it found a
solution and that is stated in the message in the Goal Seek Status dialog box. You can see the former
value in cell E3 has changed to 30 in the table. That means that, to sell 1000 pieces of the items for a goal
profit of N45,000, you have to sell at the rate of N30 apiece.
Exercise 3
As a follow up to exercise 2 above, you had a deliberation with your staff and agreed that a price change
from N25 to N30 is not a wonderful idea, that it may be better to sell more items. However, you still
want a profit of N45 000. Use Goal Seek to find out how many items you will have to sell to meet your
new profit figure.
5.2
Using the Scenario Manager
The scenario manager is one of the features under
the "What-If Analysis" in Excel. They are similar to
data tables in that you are changing values to get
new results.
We will see how they work now, as we tackle a
family budget. So, create the spreadsheet below:
The figure in B12 above is just a SUM function,
and is your total debts. The figure in D3 is how
much you have to spend each month (not a lot!). The
figure in D13 is how much you have left after you
deduct all your debts.
39
With only 4,600Naira spending money left each month, clearly some changes have to be made. We'll
create a scenario to see what effect the various budgets cuts have.
Under Data tab, in the Data Tools group, click What if Analysis and select Scenario Manager from the
menu to get the Scenario Manager dialogue box:
Click the Add button to get the Add Scenario another dialogue box:
Figure 5.2B1 Add Scenario Dialogue Box
The J22 in the image is just whatever cell you had selected when you brought up the dialogue boxes.
We'll change this. First, type a Name for your Scenario in the Scenario Name box. Call it Original Budget.
Excel now needs you to enter which cells in your spreadsheet will be changing. In this first scenario,
nothing will be changing (because it's our original). But we still need to specify which cells will be
changing. Let Us try to reduce the Food bill, the Clothes Bill, and the Phone bill. These are in cells B7 to
B9 in our spreadsheet. So in the Changing Cells box, enter B7:B9
Click OK and Excel will ask you for some values:
We do not want any values to change in this first
scenario, so just click OK. You will be taken back to
the Scenario Manager box. It should now look like
this:
Now that we have one scenario set up, we can add a
second one. This is where we will enter some new
values - our savings.
Figure 5.2c Scenario Values Dialog Box1
You will be taken to the Scenario Values dialogue box again. This time, we do want to change the values.
Enter the same ones as in the image below:
41
click inside it again with the CTRL key held down. Click OK when you have selected the cells you want.
Excel will create
5.3
Data Tables in Excel
Data Table helps us to see different results by altering an input cell in a formula. Example; we are going to
alter the interest rate, and see how much a 10,000 loan would cost each month. The interest rate will be
our input cell.
By asking Excel to alter this input, we can quickly see the different monthly payments. We want to know
how much we would pay back each month if the interest was 24% per year. But other banks may be
offering better deals. So we will ask Excel to calculate how much we would pay each month if the interest
rate was 22% a year, 20% a year, or 18% a year.
Make the following entries into an Excel sheet:
Click cell D2 and enter the formula, =PMT(B3 / 12, B4, -B5) When you press the enter key on your
keyboard, Excel should give you an answer of 287.68.
42
Now that we have our function in place, we can create an Excel Data Table. First, though, we need to tell
Excel about those other interest rates. It will use these to work out the new monthly payments.
Remember, Excel is recalculating the PMT function. So it needs some new values to calculate with.
We have put the PMT function in cell D2 for a reason. This is one Row up, and one Column to the right of
our first new interest rate of 22%. The new monthly payments are going to go in cells D3 to D5. Excel needs
the table setting out this way.
So that Excel can work out the new totals, you have to highlight both the new values and the Function
you're using. So highlight the cells C2 to D5.
As you can see, the cells C2 to D5 are now highlighted. This includes our new interest rate values in the C
column and our PMT function in cell D2. We can now create an Excel Data Table, which will work out new
monthly payments for us. So do this:
1. Click on the Data tab.
2. Choose What-If Analysis from the Data Tools group of the Ribbon to open the drop down list.
3. Click on Data Table... in the list to bring up the Data Table dialog box.
In the dialogue box, there is only a Row input cell or a Column input cell. We want Excel to fill downwards,
down a column. So we need the second text box on the dialogue box "Column input cell". If we were filling
across in rows, we would use the "Row input cell" text box. The Input Cell for us is the one that contains
our original interest rate. This is the cell you want Excel to substitute. Continue with the steps below:
4. Click inside the Column input cell box and enter B3:
5. Click OK. When you do, Excel will work out the new monthly payments:
So if we could get an 18 percent interest rate, our monthly payments would be 253.93. If you click inside
any of the cells D3:D5, then look at the formula bar, you will see this:
{=TABLE(,B3)}; Excel has created Table based on the input of cell B3
43
CHAPTER SIX
FUNCTIONS
6.1
DATE FUNCTIONS
6.1.1 Excel Date & Time System:
Excel stores all dates as integers and all times as decimal fractions. With this system, Excel can add,
subtract, or compare dates and times just like any other numbers, and all dates are manipulated by using
this system.
In this system, the serial number 1 represents 1/1/1900 12:00:00 a.m. So;
Jan 1, 1900 = 1
Jan 2, 1900 = 2
Jan 3, 1900 = 3
and so on.
Times are stored as decimal numbers between .0 and .99999, where .0 is 00:00:00 and .99999 is
23:59:59. The date integers and time decimal fractions can be combined to create numbers that have a
decimal and an integer portion. For example, the number 32331.06 represents the date and time
7/7/1988 1:26:24 a.m.
To help you perform complex date and time calculations, Excel includes many built-in date and time
functions.
6.1.2 NOW Function:
Add Today's Date and/or Time to an Excel Spreadsheet
The NOW function, one of Excel's date and time functions, is used to add the current time and date to a
spreadsheet.
The syntax for the NOW function is: = NOW ( )
Note: The NOW function takes no arguments.
Example: Using Excel's NOW Function
1. Click on a cell, e.g. D1 - the location where the results will be displayed.
2. Click on the Formulas tab.
3. Choose Date & Time from the ribbon to open the function drop down list.
4. Click on NOW in the list to bring up the function's dialog box.
5. Click OK.
6. The current time and date should appear in cell D1.
7. When you click on cell D1 the complete function = NOW ( ) appears in the formula bar.
8. If you want cell D1 to show only the current time or date, change the cell's format to show either time
or date only.
6.1.3 DATEDIF FUNCTION:
Counts the Number of Days between Dates in Excel. The DATEDIF function can be used to calculate the
number of days between two dates. An interesting point about DATEDIF is that it is an "undocumented"
function which means it is not listed with other functions under the Formulas tab in Excel 2007 and 2010.
To use the function you must type it manually into a cell on the worksheet rather than using the dialog
44
box method available for other functions. The syntax for the DATEDIF function is: = DATEDIF (start_date,
end_date, unit)
The function has three arguments that need to be entered as part of the function:
start_date - the first or starting date.
end_date - the second or last date.
unit - tells the function to find the number of days ("D"), complete months ("M"), or complete
years ("Y") between the two dates.
The unit argument can also be a combination of days, months, and years:
"YM" - excludes years - calculates the number of months between two dates as if the dates were
in the same year.
"YD" - excludes years - calculates the number of days between two dates as if the dates were in
the same year.
"MD" - excludes months - calculates the number of days between two dates as if the dates were
in the same month and year.
Example
Note: Commas are used as separators between the function's three arguments. Enter the following
dates into cells D1 and D2: 1/30/2012 and 5/18/2012
1.
2.
3.
4.
5.
Click on cell E1 in the spreadsheet - this is where the function will be located.
Type " = datedif " in cell E1.
Type an opening round bracket (after the function name in cell E1.
Click on cell D1 in the spreadsheet to enter the cell reference of the start_date into the function.
Type a comma ( , ) in cell E1 after D1 to act as a separator between the two cell references in the
function.
6. Click on cell D2 in the spreadsheet to enter the cell reference of the end_date into the function after
the first comma.
7. Type a second comma ( , ) in cell E1 following the second cell reference as a second separator.
8. For the unit argument, type the letter D in quotes ("D" ) in cell E1 after the second comma to tell the
function we want to know the number of days between the two dates.
9. Type the closing bracket " ) " .
10. Press the ENTER key on the keyboard.
11. The answer 108 should appear in cell E1 as there are 109 days between January 30th and May 18.
12. If you click on cell C1, the complete function = DATEDIF ( D1 , D2 , "D" ) appears in the formula bar
above the worksheet.
If you get a #NUM! error in the cell where your function is located, it means that the start_date is larger
(later in the year) than the end_date.
45
6.2
LOGICAL FUNCTIONS
These functions return only a true or false answer. They can be used individually or combined with one
or more other functions.
6.2.1 The AND Function
The AND function is one of Excels Logical functions. Like other logical functions, the AND function gives
only a TRUE or FALSE answer. To determine whether the output will be TRUE or FALSE, the AND function
evaluates at least one mathematical expression located in another cell in the spreadsheet.
The syntax for the AND function is:
Figure 6.2.1
46
= OR (logical-1, logical-2,...logical-255 )
Where logical - refers to the cell reference being checked. Up to
255 logical values can be entered into the function.
Example:
The function
= OR (B1 > 100, B2 > 100, B3 > 100) returned
TRUE in C1 for the values in B1:B3 because at
least one value satisfies the condition.
Figure 6.2.2
6.3
The IF Function
The IF function, tests to see if a certain condition is true or false. If the condition is true, the function will
carry out one action. If the condition is false, it will carry out a different action.
The syntax for the IF function is:
=IF (logical_test, value_if_true, value_if_false)
Where; logical_test: is a value or expression that is tested to see if it is true or false.
value_if_true: is the value that is displayed if logical_test is true.
value_if_false: is the value that is displayed if logical_test is false.
Consider the following examples:
Example 1:
If for a bagging process, we have; IF (Weight<50, E1+1, D1+1)
It means, if weight is less than 50, add 1 to content of cell E1 else, add 1 to content of cell D1.
Example 2:
A payroll system with an input from the Welfare department built in that demands that when a staffs
total deduction exceeds half of his expected take-home salary, that the system should deduct only three
quarters (not all) of the total deduction. See the IF statement of the logic in cell E2 below:
47
Exercise: 3
Now, get the Insert Function dialogue box, then the Function Arguments dialogue box and repeat the
above payroll exercise by yourself.
Figure 6.3b
48
Exercise 4: This exercise now uses the IF function and applies both relative and absolute cell referencing.
See table below:
Note that:
As the function is copied,
Excel updates the relative
cell references to reflect
the
function's
new
location while keeping the
absolute cell reference the
same.
Figure 6.3c
6.4
Combining the AND and OR Function with the IF Function in Excel
By themselves, the AND and OR function have limited usefulness. By combining them with another
function, such as the IF function, they can increase the capabilities of your spreadsheet.
Example
Assuming this function is located in cell C1, if all three of these cells (B1, B2, and B3) contains a value
greater than 100, the IF function will show the statement Over Budget in cell C1.
If any of these three cells contain a number less than or equal to 100, the IF function will show the
statement Acceptable in cell C1.
Example Nesting an OR function inside an IF function; enter the following data into an Excel sheet:
Assuming this function is located in cell E1, if any of these three cells (D1, D2, or D3) contains a value
greater than 100, the IF function will show the statement Over Budget in cell E1. If all three cells have
numbers less than or equal to 100, the IF function will show the statement Acceptable in cell E1.
49
6.5
TEXT FUNCTIONS
The syntax for the CONCATENATE function is: = CONCATENATE (text1, text2, ... text255 )
Text1, text2, ... text255 can be words, cell references, blank spaces, or numbers. Up to 255 text entries
can be added to the CONCATENATE function. Each entry must be separated by a comma.
6.5.1.1
LEFT FUNCTION
LEFT returns the first character or characters in a text string, based on the number of characters you
specify. It has the following syntax: LEFT(text, [num_chars])
6.5.1.2
RIGHT FUNCTION:
RIGHT returns the last character or characters in a text string, based on the number of characters you
specify. It has the following syntax: RIGHT(text,[num_chars])
Now try out the RIGHT function by yourself.
50
6.5.1.3
MID FUNCTION:
MID returns a specific number of characters from a text string, starting at the position you specify, based
on the number of characters you specify.
It has the following syntax: MID(text, start_num, num_chars)
The MID function syntax has the following arguments:
text: Required. The text string containing the characters you want to extract.
start_num: Required. The position of the first character you want to extract in text. The first
character in text has start_num 1, and so on.
num_chars: Required. Specifies the number of characters you want MID to return from text.
Note:
1. If start_num is greater than the length of text, MID returns "" (empty text).
2. If start_num is less than the length of text, but start_num plus num_chars exceeds the length
of text, MID returns the characters up to the end of text.
3. If start_num is less than 1, MID returns the #VALUE! error value.
4. If num_chars is negative, MID returns the #VALUE! error value.
6.5.1.4
LEN FUNCTION:
LEN returns the number of characters in a text string. It has the following syntax: LEN(text)
51
The Column Index Number: The column index number indicates which column of the table array
contains the data you are after. For example:
If you enter a 1 into the column index number, VLOOKUP returns a value from the first column in
table_array;
If the column index number is 2, it returns a value from the second column in table_array.
The Range Lookup Value:
Note: For help with these instructions, see the image above. The range lookup value is a logical value
(TRUE or FALSE only) that indicates whether you want VLOOKUP to find an exact or an approximate
match to the lookup value.
If TRUE or if this argument is omitted, VLOOKUP will use an approximate match if it cannot find an
exact match to the lookup_value. If an exact match is not found, VLOOKUP uses the next largest
lookup value.
If FALSE, VLOOKUP will only use an exact match to the lookup_value. If there are two or more
values in the first column of table_array that match the lookup value, the first value found is used.
If an exact match is not found, an #N/A error is returned.
Enter the data as seen in the image above into cells D4 to E10. The first column of data (column D) contains
the part names. The second column (column E) the price of each part.
1.
2.
3.
4.
5.
6.
8. Click on cell D2 to add this cell reference to the lookup_value line. This is the cell where we will
type the part name about which we are seeking information.
9. Press the F4 key on the keyboard to make the cell reference absolute.
10. Click on the table_array line in the dialog box.
11. Drag select cells D5 to E10 in the spreadsheet to add this range to the table_array line. This is the
range of data that VLOOKUP will search.
12. Press the F4 key on the keyboard to make the range absolute.
13. Click on the Col_index_num line in the dialog box
14. Type a 2 in this line to indicate that we want VLOOKUP to return information from the second
column of the table array.
15. Click on the Range_lookup line in the dialog box
16. Type the word False in this line to indicate that we want VLOOKUP to return an exact match for the
data we are seeking.
17. Click OK to close dialog box.
18. If you have followed all the steps of this tutorial you will have a complete VLOOKUP function in cell
E2:
=VLOOKUP($D$2,$D$5:$E$10,2,FALSE)
6.6.1.2 Excel VLOOKUP Error Messages
The following error messages are associated with VLOOKUP.
1. #N/A error :
This error is displayed if the lookup value is not found in the first column of the table array.
It will also be displayed if the range for the table array argument is inaccurate. If this argument includes
empty columns on the left of the table array.
2. #REF!: This error is displayed if the column index number argument is greater than the number of
columns in table array.
2. If done correctly, the dialog box will close and a #N/A error will appear in cell E2 - the cell where we
entered the VLOOKUP function.
3. The #N/A error appears in cell E2 because cell D2 is blank. Cell D2 is where we told VLOOKUP to find
the Lookup_value in step 3 of the tutorial. Once data is added to cell D2, the error will be replaced by
information from the database.
4. Click on any of the cells having the #N/A error, if you entered the VLookup formula correcting the
formula bar will read: {=VLOOKUP(E2,E5:G10,{2,3,4},FALSE)}
HLOOKUP works much the same Excel's VLOOKUP function. The only difference being that VLOOKUP
searches for data in columns while HLOOKUP searches for data in rows.
1. Enter the data as seen in the image above into cells D4 to I5.
The first row of data (row 4) contains the part names.
The second row (row 5) the price of each part.
Cell D1 contains the text Part Name
Cell D2 contains the text Price
Cell E2 contains the HLOOKUP Function
2.
3.
4.
5.
6.8
TROUBLESHOOTING FUNCTIONS
This section exposes students to Excels capabilities in determining the cause of error in the formula
entered into cells.
Given the expression in cell E2, =Mid(C2,3,50)*D2 results in the #VALUE! Error.
Class work: Can anyone in the class, quickly tell us the cause of the error?
You can use Excels Evaluate Formula command to determine the cause of the error as follows:
1. Click the cell containing the error, in this case cell E2
2. Click the Formula tab and from the Formula Ribbon, in the Formula Auditing area, click Evaluate
Formula. The Evaluate Formula dialog box is displayed.
56
57
CHAPTER SEVEN
7.1
MACROS
MACROS
When you find yourself repeatedly performing the same actions or tasks in a spreadsheet,
then it is time for you to create a macro. A macro is a recording of each command and
action you perform to complete a task. Then, whenever you need to carry out that task in a
spreadsheet, you just run the macro instead.
Macros can be activated by a couple of keystrokes or by a worksheet button so they are
easy to execute, and, provided they were recorded correctly, they will always carry out the
same steps in the same order with no chance for operator error.
The macro recorder works by recording all keystrokes and clicks of the mouse.
In Excel, all macro - related commands are located under the Developer tab, in the Code
group of the ribbon; if it is not there, follow the steps below to add it.
7.1
7.2
1.
2.
3.
4.
5.
6.
7.
58
7.3
Recording a Macro
1. Click on the Developers tab.
2. Click on Record Macro in the ribbon
to open the Record Macro dialog box.
60
CHAPTER EIGHT
8.1
The data that went in to our lists doesn't need to be on show for all to see. You can
hide this text quite easily.
Highlight the columns with your data in it (F, G and H for us)
Click on the Home tab from the top of Excel
Locate the Cells panel
On the Cells panel, click on Format. You'll see the following menu:
Move your mouse down to Hide & Unhide and you'll see a Sub Menu appear:
Click on Hide Columns from the Sub menu. Excel will hide the columns you
selected:
In the spreadsheet above, the columns F to H are no longer visible.
To get them back again, highlight the columns E and I. From the same sub menu,
click Unhide Columns.
8.2 WORKING WITH TEMPLATES
Change an Excel Template
After selection a template, you can change the template and save it for later use.
Make changes to the selected template
61
4. Click Save.
Click on Insert Tab on the Ribbon and click Header & Footer on the Text Group
Select Picture button on the Header & Footer Elements group
From the Insert Picture Dialog box, select a picture you want to add as water mark and click Insert button
Press the Enter key severally to center the image icon on the sheet
If you want the image to fade out, select the picture icon and click on Format Picture on the Header &
Footer Elements group
6. Then, from the Format Picture Dialog box, select Picture tab and choose Washout color under Image
control.
63