TABLE of CONTENT
PART ONE: THE EXCEL ENVIRONMENT
INTRODUCTION.......................................................................................................................... 5
What Is Excel? ............................................................................................................................ 6
Rows, Columns, Cells, Range Of Cells ......................................................................................... 7
Worksheet, Sheet Tab, Workbook ............................................................................................. 8
Ribbons, Quick Access Toolbar (QAT), & File Backstage View .................................................. 10
Excel Names -- Named Ranges ................................................................................................. 13
Remove Duplicates .................................................................................................................. 16
Data Validation ........................................................................................................................ 18
Relative, Absolute AND Mixed Cell Reference.......................................................................... 21
PART TWO: CALCULATING WITH EXCEL
Create Basic Formulas .............................................................................................................. 24
Calculate with Functions .......................................................................................................... 25
SUM FUNCTIONS ..................................................................................................................... 26
Count Functions ....................................................................................................................... 33
IF FUNCTION ............................................................................................................................ 41
VLOOKUP FUNCTION ............................................................................................................... 46
SEARCH FUNCTION .................................................................................................................. 50
INDEX FUNCTION ..................................................................................................................... 54
MATCH FUNCTION ................................................................................................................... 60
INDIRECT FUNCTION ................................................................................................................ 63
INTRODUCTION
Excel is Fun! Why? Because youre efficient use of Excel can turn a three hour payroll calculating chore or a
five hour reporting task into a five minute breeze. Efficient use of Excel will save a lot of time. That time
adds up to extra time for your more enjoyable endeavors in life such as vacations! In addition, your bosses
and employees will notice that you are efficient and can produce professional looking reports that impress.
This of course leads to promotion more quickly. Still, further, your knowledgeable and efficient use of Excel
can land you a job during an interview. Employers are like dry sponges ready to soak up any job candidate
that can make their entity more efficient with Excel skills! Save time? Get promoted? Get the job? And
have more time for vacation? That sounds like a great skill to have!
In the working world, almost everyone is required to use Excel. Amongst the people who are required to
use it, very few know how to use it well; and even amongst the people who know it well, very few of those
people know how to use it efficiently to the point where grace and beauty can be seen in a simple
spreadsheet!
This book will take you from the very beginning basics of Excel and then straight into a simple set of
efficiency rules that will lead you towards Excel excellence.
What Is Excel?
You use Word to create letters, flyers, books and mail merges. You use PowerPoint to create visual, audio
and text presentations. You use Google to research a topic and find the local pizza restaurant. You use
Excel to make Calculations, Analyze Data and Create Charts. Although databases (such as Access) are the
proper place to store data and create routine calculating queries, many people around the planet earth use
Excel to complete these tasks. Excels row and column format and ready ability to store data and make
calculations make it easy to use when compared to a database program. However, Excels essential beauty
is that you can make calculations and analyze/manipulate data quickly and easily on the fly! This easy to
use, planet-earth default program must be learned if you want to succeed in todays working world.
Open up the Excel file named LearningEXCEL 2010.xlsx and with your mouse, click on the What is Excel
sheet tab.
Here is an example of how Excel can make payroll Calculations quickly and with fewer errors than doing it
by hand.
Name Box
Sheet tab
Rows and
Columns
Rows are horizontal and are represented by numbers. In our example the color blue has been added to
show row 5.
Columns are vertical and represented by letters. In our example the color yellow has been added to show
Column B.
A cell is an intersection of a row and a column. In our example the color green has been added to show cell
B5. In our example column B and row 5 can be detected because the column and row headers are
highlighted in a light-orange color (Figure 4)(color may vary by computer). In addition, you can see that the
name box shows that cell B5 is selected (Figure 4and Figure 5).
B5 is the name of this cell. It can be thought of as the address for this cell. It is like the intersection of two
streets. If we wanted to hang out at the corner of Column B Street and Row 5 Street, we would be hanging
out at the cell address B5.
Later when we make calculations in Excel (making formulas), B5 will be called a cell reference.
A range of cells is two or more cells that are adjacent. For example you
can see three blue cells D9, E9, and F9. This range would properly be
expressed as D9:F9, where the colon means from cell D9 all the way to cell F9.
2007/2010 workbook that allows Macros (Macros = custom code that you can put in
workbook (VBA))
ii. This file format is called XML (Extensible Markup Language). XML is efficient because:
1. Most any program can read it
2. It is less corruptible
i. Lose a few lines in BIFF and you can lose the whole file, lose a few lines in
XML and you can easily recover the file
iii. This new file format is different than XML in 2003 (2003 XML did not support VBA,
Charts, and other embedded images), it now supports all Excel elements.
iv. These files are actually zipped files!!!!
i. Saves space
2. xlsx
i.
This is the same as the description for .xlsm except that does not allow Macros (Macros
= custom code that you can put in workbook(VBA))
i.
3. .xls
4. .htm
i. Saves worksheet or workbook as html (web site)
5. .xltm
i. 2007/2010 Excel Template that allows Macros
1. Templates automatically save to the Microsoft Template folder so that your
template will show up in the Templates window
6. .xlt
i. 1997 2003 file format for Templates
7. .xlsb
i.
Figure 1
File tab
QAT
Examples of Groups on
the Home Ribbon
Examples of icon
buttons
The File tab is located in the upper left corner of the screen, to the left of the Home Ribbon tab. If you click
on it opens the backstage view. On the next page shows the File Backstage View and shows that this
10
allows you to access things such as Print, Save As and Recent. On the
next page shows the amazing recent option that allows you to open
recently accessed files and folders. THE MOST IMPORTANT thing to know about the backstage view is that
when you want to close this view DO NOT USE THE x IN THE UPPER RIGHT CORNER. To close use the
Exit button in the lower left or simply use the Esc key.
The Quick Access Toolbar (QAT) contains the icons for save, undo and redo by default and then any other
additional icons that you add yourself. There is only one QAT. The QAT is always visible and available for
use, either above the Ribbons or below the Ribbons depending on where you place it (right-click QAT to
move it). We will see how to customize the QAT later in this book.
11
12
13
1. Select the labels and the cells that are to be named. The labels
can be above, below, left or right of the cells to be named. In this
example, the labels are in column B, to the left of the cells that will be named.
2. On the Ribbon, click the Formulas tab, and then click Create from Selection.
3. In the Create from Selection window, add a check mark for the location of the labels, and then click
OK. In this example, the labels are in the left column of the selected cells.
4. Click on a cell to see its name. In the screen shot below, cell C4 is selected, and you can see its
name in the Name Box -- Full_Name.
o NOTE: If the labels contain spaces, they're replaced with an underscore. Other invalid
characters, such as & and # will be removed, or replaced by an underscore character.
14
Use Names
After creating names that refer to a range, you can select a name in the Name Box dropdown list, to select
the named range on the worksheet.
You can also use names in formulas. For example, you could have a group of cells with sales amounts for
the month of January. Name those cells JanSales, and then use this formula to calculate the total amount:
=SUM(JanSales)
In the following example, the names TotalSales and TaxRate have been defined.
=TotalSale * TaxRate
15
Remove Duplicates
In Excel 2007, there's a new command on the Ribbon to make it easier to remove duplicates from a list.
How It Works
In this example, the list in cells A1:A10 contains a few duplicates.
3. In the Remove Duplicates dialog box, select the column(s) that you want to remove duplicates from
4. Check the box for My Data Has Headers, if applicable, then click OK.
16
5. A confirmation message will appear, showing the number of duplicates removed, and the number
of unique items remaining. Click OK to close the message.
17
Data Validation
In Excel, the data validation feature helps you control what can be entered in your worksheet. For
example, you can:
18
Select the cells in which you want the drop down list
On the Ribbon's Data tab, click Data Validation.
From the Allow drop-down list, choose List
Click in the Source box, and type an equal sign, and the list name, for example:
=EmpNames
OR, press the F3 key, to see a list of names, click on a name, and click OK
19
20
1.
2.
3.
4.
Relative
Absolute
Mixed Cell Reference with Column Locked also known as Column Absolute, Row Relative
Mixed Cell Reference with Row Lockedalso known as Row Absolute, Column Relative
It will only be possible to understand these if we look at a few examples. Nevertheless, here are the crucial facts
about cell references:
Example: A1
No dollar signs
Moves relatively throughout copy action
Relatively means that if the formula is looking at a cell reference that is three cells to the left,
when you copy the formula to any other cell, the cell reference will still be looking three cells to the
left.
Example: $A$1
Example: $A1
21
Example:
A$1
Dollar sign before row designation
Remains absolute or locked when copying across rows
Remains relative when copying across columns
Locks cell reference when copying it vertically, but not horizontally
Keyboard shortcut F4 key:Toggles between the four types of cell references
When creating formulas with cell references, ask two questions of every cell reference in formula:
Q1: What do you want it to do when you copy it horizontally?
Is it a relative reference? OR
Is it an absolute or locked reference?
Q2: What do you want it to do when you copy it vertically?
Is it a relative reference? OR
Is it an absolute or locked reference?
22
23
24
25
SUM FUNCTIONS
Sum a range of cells -- SUM Function
The SUM function will add the numbers in a range of cells. Its syntax is:
=SUM(number1, number2,...number30).
The arguments (e.g. number1) for the SUM function can be cell references, or typed into the formula. The
following example uses one argument -- a reference to cells A1:A4.
1. Select the blank cell in the row below the cells that you want to sum, cell A5 in this example.
2. Click the AutoSum command on the Ribbon's Home tab
26
2. Click the AutoSum button on the Ribbon's Home tab. A SUM formula will be automatically entered
for each Total.
Sum cells that match criteria -- SUMIF
Match criterion exactly
You can calculate a total for rows that meet a specific criterion. In this example only the rows with Pen
orders will be included in the total.
1.
2.
3.
4.
27
Note: Instead of typing the criterion in a formula, you can refer to a cell. For example, the formula in step 9
above could be changed to:
=SUMIF(A2:A10, B12, B2:B10)
if cell B12 contained the text pen.
Match criterion in a string
You can add cells that contain a criterion as part of the cell's contents. In this example all Pen, Gel Pen, and
Pencil orders will be summed, because they contain the string "pen".
1.
2.
3.
4.
Select the cell in which you want to see the total (cell A12 in this example)
Type an equal sign (=) to start the formula
Type: SUMIF(
Select the cells that contain the values to check for the criterion. In this example, cells A2:A10 will
be checked
5. Type a comma, to separate the arguments
6. Type the criterion. In this example, you're checking for text, so type the word in double quotes,
with one or more asterisk (*) wildcard characters: "*Pen*"
Note: upper and lower case are treated equally
7. Type a comma, to separate the arguments
8. Select the cells that contain the values to sum. In this example, cells B2:B10 will be summed
9. Type a closing bracket. The completed formula is: =SUMIF(A2:A10,"*Pen*",B2:B10)
10. Press the Enter key to complete the entry
11. The result will be 53, the total of rows that contain the string, "Pen"
28
Note: Instead of typing the criterion in a formula, you can refer to a cell. For example, the formula in step 9
above could be changed to:
=SUMIF(A2:A10,"*" & B12 & "*",B2:B10)
if cell B12 contained the text pen.
Criterion and operator
You can use an operator with a criterion. In this example only the rows where the number of sales reps is
greater than or equal to ten will be included in the total.
1.
2.
3.
4.
29
Note: Instead of typing the criterion in a formula, you can refer to a cell. For example, the formula in step 9
above could be changed to:
=SUMIF(B2:B10,">=" & B12,C2:C10)
if cell B12 contained the number 10.
Sum cells that match multiple criteria -- SUMIFS
Match multiple criteria
In Excel 2007 and later versions, you can use the SUMIFS function to calculate a total for rows that meet
two or more criteria. In this example only the rows where the status is "Active" and the number of visits is
greater than or equal to ten will be included in the total.
3. Type: SUMIFS(
4. Select the cells that contain the values to sum. In this example,
cells C2:C6 will be summed
5. Type a comma, and then select the cells that contain the values to check for the first criterion. In
this example, cells A2:A6 will be checked
6. Type a comma, and then type the first criterion, "Active"
7. Type a comma, and then select the cells that contain the values to check for the second criterion. In
this example, cells B2:B6 will be checked
8. Type a comma, and then type the second criterion: " >=10"
9. Finish with a closing bracket: )
10. The completed formula is:
=SUMIFS(C2:C6,A2:A6,"Active",B2:B6,">=10")
11. Press the Enter key to complete the entry
Sum the Top 5 Numbers in a List
Use the SUM function and LARGE functions together, to add the largest numbers in the list.
Version 1 -- Few Top Numbers
If a few numbers are to be summed, e.g. top 3, you can type the numbers into the formula. For example:
=SUM(LARGE(A1:A7,{1,2,3}))
The result is 70+60+50 = 180
Note: The second 50 is not included in the result, even though it is tied for 3rd place.
include. In this example, rows 1:10 are used, so the top 10 numbers in
the referenced range will be summed.
1. Type the formula:
=SUM(LARGE(A1:A50,ROW(INDIRECT("1:10"))))
2. This is an array formula, and must be array-entered. To do this, hold the Ctrl and Shift keys, and
press Enter
Version 3 -- Variable Top Numbers
If a variable number of top numbers are to be summed you can include the INDIRECT function in the
formula with the SUM function, as shown above, and refer to a cell that holds the variable..
1. In cell C1, type the number of top cells, e.g. 10
2. Type the formula:
=SUM(LARGE(A1:A7,ROW(INDIRECT("1:"&C1))))
3. This is an array formula, and must be array-entered. To do this, hold the Ctrl and Shift keys, and
press Enter
32
Count Functions
How to count Excel cells with numbers, text, blanks, or cells that contain specific words or other criteria?
Count Cells with Numbers -- Excel COUNT
The COUNT function will count cells that contain numbers. Its syntax is:
=COUNT(value1, value2,...value30).
The arguments (e.g. value1) can be cell references, or values typed into the COUNT formula.
The following COUNT function example uses one argument -- a reference to cells A1:A5.
1. Enter the sample data on your worksheet
2. In cell A7, enter an COUNT formula, to count the numbers in column A: =COUNT(A1:A5)
33
34
Select the cell in which you want to see the count (cell A12 in this example)
Type an equal sign (=) to start the formula
Type: COUNTIF(
Select the cells that contain the values to check for the criterion. In this example, cells A1:A10 will
be checked
5. Type a comma, to separate the arguments
6. Type the criterion. In this example, you're checking for text, so type the word in double quotes:
"Pen"
Note: upper and lower case are treated equally
7. Type a closing bracket
The completed formula is: =COUNTIF(A1:A10,"Pen")
35
4. Select the cells that contain the values to check for the criterion.
In this example, cells A1:A10 will be checked
5. Type a comma, to separate the arguments
6. Type the criterion. In this example, you're checking for text, so type the word in double quotes,
with one or more asterisk (*) wildcard characters: "*Pen*"
Note: upper and lower case are treated equally
7. Type a closing bracket
The completed formula is: =COUNTIF(A1:A10,"*Pen*")
Select the cell in which you want to see the count (cell A12 in this example)
Type an equal sign (=) to start the formula
Type: COUNTIF(
Select the cells that contain the values to check for the criterion. In this example, cells B1:B10 will
be checked
5. Type a comma, to separate the arguments
6. Type the criterion. In this example, you're checking for rows where the quantity is greater than or
equal to 10. The >= operator is used before the number, and the entire criterion is enclosed in
36
Note: Instead of typing the criterion in a formula, you can refer to a cell. For example, the formula in step 8
above could be changed to:
=COUNTIF(B1:B10,">=" & B12)
if cell B12 contained the number 10.
Match criteria in a range
You can combine COUNTIF formulas, to count rows that are within a range of values. In this example, the
formula will count rows where the quantity is between 5 and 10 (inclusive).
1. Select the cell in which you want to see the count (cell A12 in this example)
2. Type a formula to count rows greater than or equal to 5:
=COUNTIF(B1:B10,">=5")
3. Type a minus sign
4. Type a formula to count rows greater than 10:
COUNTIF(B1:B10,">10")
5. The completed formula is:
=COUNTIF(B1:B10,">=5")-COUNTIF(B1:B10,">10")
6. Press the Enter key to complete the entry
37
Note: Instead of typing the criterion in a formula, you can refer to a cell. For example, the formula in step 8
above could be changed to:
=COUNTIF(B1:B10,">=" & B12) COUNTIF(B1:B10,">" & C12)
if cell B12 contained the number 5 and cell C12 contained the number 10.
Change Operator for COUNTIF Function
Instead of typing the operator into the COUNTIF formula, as shown above, you can create a list of all
possible operators, and select one from a drop down list. Then, refer to that operator in the formula.
Create a Drop Down List of Operators
To create a drop down list operators:
1. On a different sheet in the workbook, type a list of operators in a column.
2. Select the cells in the list, and Name that list as OpList.
3. On the main sheet, select the cell where you want the drop down list.
4. Use the data validation command to create the drop down list, based on the named range -- OpList
38
Select one of the operators, from the drop down list, and the formula result will change.
Count cells that match multiple criteria -- COUNTIFS
4. Select the cells that contain the values to check for the first
criterion. In this example, cells A2:A10 will be checked
5. Type a comma, and the first criterion: "Pen"
Note: Because this is a text criterion, it is enclosed in double quote marks.
6. To start the next set of criteria, type a comma
7. Select the cells that contain the values to check for the second criterion. In this example,
cells B2:B10 will be checked
8. Type a comma, and the second criterion: ">=10"
Note: Because this criterion includes operators, it is enclosed in double quote marks. To count rows
where the quantity is equal to 10, only the number 10 would be required.
9. Finish with a closing bracket: )
10. The completed formula is shown below.
11. Press the Enter key to complete the entry
Note: Instead of typing the criterion in a formula, you can refer to a cell, as shown in the second formula
below. If using operators, enclose them in double quote marks.
40
IF FUNCTION
In this next section we will talk about a built-in Excel function called the IF function. The IF function is great
for when you need to put one of two things into a cell. For example, when you are calculating whether or
not you get a bonus at work, you would say something like, If I make sales over or equal to $5,000, I get a
$100 bonus, otherwise I get no bonus. Notice that the words that we use to describe whether or not we
get a bonus start with the word If! This is why Excel named the function IF.
In our case the logical test would be: Sales >=$5,000 (in words: If I make sales over or equal to $5,000).
This logical test will either be TRUE or FALSE. If the logical test is TRUE, then we get our bonus of $100. If
the logical test is FALSE, then we get a bonus of $0 (we did not exceed or equal the sales hurdle of $5,000).
Thebuilt-in Excel IF function will automatically tell you whether or not you earned a bonus! All you have to
do is tell the IF function three things:
1. What the logical test is
2. What the bonus amount is (Value to put in the cell if the logical test turns out to be TRUE)
3. What the amount is if we dont make the sales hurdle. (Value to put in the cell if the logical test
turns out to be FALSE)
In Excel language (and math language) the three things are called arguments. So our three arguments for
the IF function will be:
1) Logical test
2) Value if TRUE
3) Value if FALSE
The function will look like this:
=IF(logical_test,[value_if_true],[value_if_false])
The great thing about the IF function is that whenever you have one of two things to put in a cell that
depend of a logical test that comes out to be TRUE or FALSE, you can use the IF function. In addition, the
two things that you want to put in a cell that depend on a logical test can be numbers, text, cell references,
or other formulas.
41
2. Click in cell B14 and type the beginning few characters of our formula: =IF(. In Next Figure you
can see the beginning characters of our formula in the cell B14 and in the formula bar. You can
also see a function screen tip that gives you a hint of what arguments are required.
=IF(
42
3. Type the logical test, this logical test says If Sales are greater
than or equal to the Sales Hurdle. This logical test will come
out to be TRUE or FALSE.
4. Next, we type a comma. As seen, the screen tip highlights with bold the next argument that is
needed. We can see that we must tell the IF function what to put in the cell if the logical test
comes out to be TRUE.
5. As seen, in order to tell the function what value goes into the cell if the logical test is TRUE, we
click on the cell with the $100 bonus, cell B11.
6. As seen, we complete the formula by adding the last argument and ending parenthesis to our IF
function. This last argument tells the IF function what to put in the cell if the logical test is
FALSE.
Hit control + Enter to enter our formula into the cell. As seen in Figure 369, the IF function delivers the
$100 bonus to the cell because our Sales number, $5,500, is above the Sales Hurdle number, $5,000. But
what if our mean boss changed the Sales Hurdle number to $6,000? What would happen to our $100
Bonus?
43
7. To see the IF function in action, pretend you are the mean boss and change the Sales Hurdle
value in cell B10 to the value $6,000 (which is above your Sales number. As seen, the IF function
looked at the logical test Sales>=$6,000 ($5,5000>=$6,000), came to a FALSE conclusion, and
then put the $0 amount in cell B14.
8. Now change your Sales number to $6,000. As seen, because the logical test Sales>=$6,000
($6,000>=$6,000) was TRUE, the TRUE amount of $100 was put into cell B14.
Before you try the remaining IF functions on your own, lets look at the completed IF function formula in
cell A19 in our formula bar. Here we can see that the logical test is whether or not Sales are greater than
Expenses (Sales>=Expenses), if this is TRUE, we want out label to read Net Income, otherwise if it is
FALSE, we want our label to read Net Loss.
44
45
VLOOKUP FUNCTION
The VLOOKUP function looks for a value in the first column in a table, and returns another value from the
same row in that table.
VLOOKUP Syntax
The VLOOKUP function has the following syntax:
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
o lookup_value: the value that you want to look for -- it can be a value, or a cell reference.
o table_array: the lookup table -- this can be a range reference or a range name, with 2 or
more columns.
o col_index_num: the column that has the value you want returned, based on the column
number within the table.
o [range_lookup]: for an exact match, use FALSE or 0; for an approximate match, use TRUE or
1, with the lookup value column sorted in ascending order..
VLOOKUP Traps
VLOOKUP can be slow, especially when doing a text string match, in an unsorted table, where an exact
match is requested. Wherever possible, use a table that is sorted by the first column, in ascending order,
and use an approximate match. You can use MATCH or COUNTIF to check for the value first, to make sure
it is in the table's first column (see example 3 below).
Other functions, such as INDEX and MATCH, can be used to return values from a table, and are more
efficient. We'll look at those functions later in the challenge, and see how flexible and powerful they are.
46
If the product name is not found in the first column of the lookup table, the VLOOKUP formula result is
#N/A
47
If the product name is not found in the first column of the lookup table, the VLOOKUP formula result is 0.
49
SEARCH FUNCTION
The SEARCH function looks for a text string, within another text string, and returns its position, if found. It
is not case sensitive.
Find a text string within another text string not case sensitive
Use wildcards in the search
Specify a start number within search text
SEARCH Syntax
The SEARCH function has the following syntax:
SEARCH(find_text,within_text,start_num)
o find_text is the text that you're looking for.
o within_text is the string that you're searching in.
o if start_num is omitted, the search starts with the first character
SEARCH Traps
The SEARCH function will return the position of the first matching string, regardless of case. If you need a
case sensitive search, use the FIND function, which we'll see later in the 30XL30D challenge.
Example 1: Find Text in a String
Use the SEARCH function to look for text within a text string. In this example, we're looking for a single
character (entered in cell B5), within a text string in cell B2.
=SEARCH(B5,B2)
50
If the text is found, the SEARCH function returns the number of its
starting position in the text string. If it's not found, the result is a
#VALUE! error.
You could use IFERROR to wrap the SEARCH function, and display a message, if the result is an error. The
IFERROR is available in Excel 2007 and later versions. For earlier versions, you can use IF with ISERROR.
=IFERROR(SEARCH(B5,B2),"Not Found")
51
There is a pipe character after each city name, so we can add a SEARCH for that. Its position can be used as
the start_number argument in the main SEARCH, so the cities will be ignored when searching.
Now, with the revised formula, only the rows with "bank" in the occupation are counted.
=ISNUMBER(SEARCH($E$1,B2,SEARCH("|",B2)))
52
53
INDEX FUNCTION
The INDEX function returns a value or reference to a value. Combine it with other functions, like MATCH,
for powerful formulas.
INDEX Syntax
The INDEX function has two syntax forms -- Array and Reference. With Array form, a value is returned, and
with Reference form, a reference is returned.
The Array form has the following syntax:
INDEX(array,row_num,column_num)
o array is an array constant or range of cells
o if array has only 1 row or column, corresponding row/column number argument is optional
o if array has >1 row or column, and only row_num or column_num is used, array of entire
row or column is returned
o row_num if omitted, column_num is required
o column_num if omitted, row_num is required
o if both the row_num and column_num arguments are used, returns value in cell at
intersection of row_num and column_num
o if row_num or column_num are zero, returns array of values for entire column or row
INDEX(reference,row_num,column_num,area_num)
o reference can refer to one or more cell ranges enclose
nonadjacent ranges in parantheses
o if each area in reference has only 1 row or column, corresponding row/column number
argument is optional
o area_num selects range in reference from which to return row and column intersection
o area_num if omitted, area 1 is used
o if row_num or column_num are zero, returns reference for entire column or row
o result is a reference, and can be used by other functions
INDEX Traps
If the row_num and column_num don't point to a cell within the array or reference, the INDEX function
returns a #REF! error.
Example 1: Find sales amount for selected month
Enter a row number, and the INDEX function returns the sales amount from that row in the reference.
Here the month number is 4, so the April sales amount is returned.
=INDEX($C$2:$C$8,F2)
To make the formula more flexible, you could use MATCH to return the row number, based on the month
that was selected from a drop down list.
=INDEX($C$2:$C$8,MATCH($F$2,$D$2:$D$8,0))
55
The INDEX function result can be multiplied, as in the Tax calculation in cell F10:
=0.05*INDEX(MonthAmts,B10,C10,D10)
or, it can return a reference for the CELL function, to show the address of the result, in cell G10.
56
=CELL("address",INDEX(MonthAmts,B10,C10,D10))
If another month is added to the list in column C, it will automatically appear in the data validation drop
down list in cell F2, which uses MonthList as its source.
57
58
59
MATCH FUNCTION
The MATCH function returns the position of a value in an array, or #N/A if not found. The array can be
sorted, or unsorted, and the MATCH function is not case sensitive.
MATCH function returns the position of the item found, not the value. If you need the value, combine
MATCH with another function, like INDEX.
60
Instead of an array reference, you can enter an array as the lookup_array argument. In this variation, the
lookup month name is entered in cell D5, and three month names are entered in the MATCH function's
second argument. If a later month, such as Oct, is entered in D5, the result will be #N/A.
=IF(C2+0<14,"Time to upgrade","Latest version")
Just as you did with VLOOKUP, you can use MATCH to help convert a student's score to a letter grade. In
this example, it is combined with CHOOSE, to get the letter grade. The match_type is -1, because the
scores are sorted in descending order.
61
When the match_type is -1, the result is the smallest value greater than
or equal to lookup value. The lookup value is 54, and it's not in the list of
scores, so the position for 60 is returned. Because 60 is in position 4, the 4th value in the CHOOSE options
is the result -- cell C6, with a value of D.
=CHOOSE(MATCH(B9,B3:B7,-1),C3,C4,C5,C6,C7)
62
The MATCH function also works well with the INDEX function, which
we'll see later in the challenge. In this example, the MATCH function is
used to find the guess that is closest to the correct number.
The ABS function returns the absolute difference between each guess and the correct number.
The MIN function finds the smallest difference.
The MATCH function finds the smallest difference in the list of differences. If there are multiple identical
differences, the first one will be returned.
The INDEX function returns the name in that position in the list of names.
=INDEX(B2:B5,MATCH(MIN(ABS(C2:C5-F1)),ABS(C2:C5-F1),0))
INDIRECT FUNCTION
The INDIRECT function returns the reference specified by a text string.
INDIRECT Syntax
The INDIRECT function has the following syntax:
INDIRECT(ref_text,a1)
o ref_text is the text string for a reference.
o a1 if TRUE or omitted, uses an A1 reference style; if FALSE, the R1C1 reference style is used
INDIRECT Traps
The INDIRECT function is volatile, so it could slow down your workbook, if used in many formulas.
If the INDIRECT function creates a reference to another workbook, that workbook must be open, or
the formula will result in a #REF! error.
If the INDIRECT function creates a reference to a range outside the row and column limit, the
formula will result in a #REF! error. (Excel 2007 and Excel 2010)
The INDIRECT function cannot resolve a reference to a dynamic named range
64
If a row is inserted at the top of the lists, and January amounts are entered, the total in column C doesn't
change. The formula changed, adjusting to the inserted row:
=SUM(C3:C8)
However, the INDIRECT function locked the starting cell to E2, so the January amount is automatically
included in the column E total. The ending cell changed, but the starting cell wasn't affected.
=SUM(INDIRECT("E2"):E8)
65
The INDIRECT function can also create a reference for a named range. In
this example, the blue cells are in a range named NumList. There is also a
dynamic range in column B, based on the count of numbers in that column.
The total for either range can be calculated, by using the range name with the SUM function, as you can
see in cells E3 and E4
=SUM(NumList) or =SUM(NumListDyn)
Instead of typing the name in the SUM formula, you can refer to the range name in a worksheet cell. For
example, with the name NumList in cell D7, the formula in cell E7 is:
=SUM(INDIRECT(D7))
Unfortunately, the INDIRECT function can't resolve a dynamic range, so when the formula is copied down
to cell E8, the result is a #REF! error.
66
In some formulas, you need an array of numbers, as in this example, where we want the average of the 3
highest numbers in column B. The numbers could be typed in the formula, as they are in cell D4:
=AVERAGE(LARGE(B1:B8,{1,2,3}))
If you need a bigger array of numbers, you probably wouldn't want to type all of them. Another option is to
use the ROW function, as in the array-entered formula in cell D5:
=AVERAGE(LARGE(B1:B8,ROW(1:3)))
67
However, if rows are inserted at the top of the sheet, the second formula returns an incorrect result,
because the rows are adjusted. Now, instead of the average of the top 3 numbers, it shows the average of
the 3rd, 4th and 5th largest numbers.
With the INDIRECT function, the third formula keeps the correct row reference, and continues to show the
correct result.
68
69
DATA ANALYSIS
70
1. Proper Excel List or Table Format, which will refer to as Excels List/Table format (this is
because in Excel 2003 it was called List and in Excel 2007 it is called Table)
2. Each row represents one Sales Transaction
i. Each sales transaction is one new record
ii. Each record is an individual collection of the seven fields
3. The first seven columns represent fields
71
72
2. Point to the drop-down arrow for the Sales field and point to Sort Largest to Smallest
3. As seen, instantly, the whole table is sorted by the sales numbers in the Sales field. We can
easily see that Sales Rep Luke had the two largest sales.
73
4. Next click on the drop-down arrow for the Sales Rep field and
click on the Sort A to Z from the drop-down list
5. As seen, instantly, the whole table is sorted by the names in the Sales Rep field, with Chin at the
top.
6. To see how to sort without the Filter turned on, turn off the Filter with the keyboard shortcut
Ctrl + Shift + L, then click in cell B6.
7. With only one cell selected in the Region field column, click the A Z icon button in the Sort
& Filter Group on the Data Ribbon.
74
NOTE: Before click the A Z icon button in the Sort & Filter Group on the Data Ribbon, make sure your
block of data is in the Proper Excel List/Table Format and highlight only one cell in the field you want to
sort.
75
76
3. As you
can see in Figure 334 Excel quickly shows us
the results. Notice two things:
1) The drop-down arrow at the top of the
Sales field contains a Filter icon to let us
know that the field has been filtered;
2) The row numbers are the color blue to let
you know that the rows with records that
are not above average have been hidden.
For example, you can see that rows 2 and 3
are hidden.
77
78
2. Subtotals are one of the greatest tricks in Excel because using the Subtotal feature quickly goes
through the whole table and inserts rows and adds totals for the column that you specify. In our
case, we will be able to very quickly add totals for all the regions and Sales Reps!
3. An important point to make here is this: DONT USE THE SUBTOTALS FEATURE FOR A PARTICULAR
FIELD UNTIL YOU HAVE SORTED THAT FIELD.
4. We have already sorted the region and the Sales Rep fields so that we can use the Subtotal feature.
5. As seen in Figure 341, click on the Subtotalsicon button in the Outline Group on the Data Ribbon.
6. You should see Subtotal dialog box as seen. Notice that the whole table was highlighted when you
invoked the Subtotals dialog box (this is because you have your data in proper Excel List/Table
format). Using the drop-down arrow for the At each change in textbox, select the Region field.
For the Use function:, use the Sum function. For the Add subtotals to: checkboxes check the
Sales field.
79
80
8. Click OK. You should see something similar to the Figure. On the
left of your screen you should see three little blue-gray boxes with the numbers 1, 2, and 3 in them.
These are called Outline buttons.
9. Click the 2 Outline button and you should see subtotals similar to those as seen. The plus and
minus symbols are collapse and expand symbols. You can use these to expose the data for a
particular Region. You can also use the 3 Outline button to expose all the records. Before you
click on the 3 Outline button, notice that there are 200 rows of sales transaction data that the
Subtotals feature traversed in less than a second! This is an amazingly efficient feature in Excel!
10. Click on the 3 Outline button to show all the records again:
82
12. As seen in the Figure, a fourth Outline Level has been added.
13. Click on the 3 Outline button. As seen in the Figure, Subtotals have been added for both the
Region and Sales Rep fields. With this Subtotal Data Analysis, we can easily pick how each Sales Rep
did in each Region.
14. To get rid of the Subtotals, use the keyboard shortcut to open the Subtotals dialog box: Alt + A + B
and then click the Remove All Button
15. In our next section we will talk about the most powerful toll in Excel, the PivotTable.
NOTE: Before adding automatic Subtotals, sort your field. If you want to add a Subtotal to a Subtotal, Be
sure to uncheck theReplace current subtotals check box.
83
Chin
Jeri
Jon
Luke
Rhonda
Sheliadawn
Steven
Troung
Grand Total
West
161,464.09
290,770.33
173,559.67
210,096.98
185,281.95
188,710.09
189,088.14
170,702.25
1,569,673.50
MidWest
247,987.69
207,164.71
231,778.99
199,211.40
192,855.38
185,465.42
165,974.78
221,063.19
1,651,501.56
North
257,832.05
169,784.64
258,672.84
231,024.41
156,087.13
169,710.11
235,576.52
227,730.44
1,706,418.14
NorthEast
486,840.62
424,234.18
334,794.87
333,815.59
402,080.39
520,169.79
500,920.09
423,634.06
3,426,489.59
SouthEast
255,416.43
220,679.39
277,404.03
208,200.24
167,137.03
156,876.25
204,597.69
233,110.32
1,723,421.38
Grand Total
1,409,540.88
1,312,633.25
1,276,210.40
1,182,348.62
1,103,441.88
1,220,931.66
1,296,157.22
1,276,240.26
10,077,504.17
2. To create something similar to what we see in Figure, make sure you have one cell in your data
table selected and that your data is in proper Excel List/Tableformat, then click on the PivotTable
icon button in the Table group on the Insert Ribbon:
84
5. In Figure we can see that the PivotTable Field List Task Pane pops up and a new sheet is added to
the workbook. All we have to do in order to create a table with the two categories Sales Rep and
Region is to click on the checkboxes for those two fields (after all this is just field list).
85
6.
As seen in Figure, by checking the two
fields, both were added as Row Labels.
Click on
the
Region
field and
drag it to
the
Column
Labels
area
7.
As seen
in Figure, because we want the Sales Rep field as a
Row Label and our Region as a Column Label, we
will click on the Region field in the Row Labels
area, hold the click, and drag it to the Column
Labels area
8.
As seen in Figure, we have our two category
labels
86
9.
As seen in Figure , we can see our PivotTable taking shape. We can
see that the Sales Rep labels and the Region labels in our worksheet. We can see that two context-sensitive
Ribbons for the PivotTable have appeared (PivotTable Tools Options and Design Ribbons).
10.
Next, as seen in Figure, click on the Sales field in the PivotTable Field List Task Pane this adds the
Sales field to the Values area. PivotTables use the Sum Function by default, which is what we wanted in our
case. To see how to change the function and to format the Sales numbers, click the close x button in the
top right corner of the PivotTable Field List Task Pane and then click in cell A3.
11.
With your cursor in cell A3, right-click and point to Value Field Settings:
87
12.
As seen in Figure, the Value Field Settings dialog box should appear: If you were to change the
function, you could do so in the Summarize value field by function list. Because we want to change the
Number formatting, we will click the Number Format button.
If you were to change the function, you
could do so in the Summarize value field
by function list.
Number Formatting
88
14.
This is another one of those situations when two dialog boxes are
opened. When the Format Cells dialog box appears, select the Currency Number format. Then click the OK
button on the Format Cells dialog box. Then click the OK button on the Value Field Settings dialog box.
15.
With only a few clicks, the PivotTable is done. Even better than with Subtotals, we can easily see
how each Sales Rep did in each Region:
89
STREAMLINING
WORKFLOW
90
Number format
Font, font style, and font colour (but not font size)
Fill colour and fill pattern
Border colour and border style (but not border thickness)
If the rules (conditions) that you specified are met, then the formatting is applied.
For example, you can set conditional formatting so that a cell turns red if its value is low, and turns green if
its value is high.
3. Select the cells to be formatted. In this example, cells E2:E7 are selected.
4. On the Ribbon's Home tab, click Conditional Formatting
5. To format the high values, click Highlight Cell Rules, then click Greater Than...
6. In the Greater Than window, delete the value that appears, and click on cell I1, where the High
value is entered.
92
7. Click the drop down list for formats, and click Custom Format.
8. In the Format Cells window, click the Fill tab, and click on the green fill color that you want.
9. Click OK to close the Format Cells window, and click OK to close the Greater Than window.
The cells with values greater than 75 are now coloured green.
93
3. To format the high values, click Highlight Cell Rules, then click Less Than...
4. In the Less Than window, delete the value that appears, and click on cell I2, where the Low value is
entered.
5. Click the drop down list for formats, and click Custom Format.
94
6. In the Format Cells window, click the Fill tab, and click on the green fill colour that you want.
7. Click OK to close the Format Cells window, and click OK to close the Less Than window.
The cells with values greater than 75 are now coloured green, and cells less than 50 are red.
95
Advanced Filter
Apply an Excel Advanced Filter
Set up the database
1.
2.
3.
4.
3.
4.
5.
6.
You can choose to filter the list in place, or copy the results to another location.
Excel should automatically detect the list range. If not, you can select the cells on the worksheet.
Select the criteria range on the worksheet
If you are copying to a new location, select a starting cell for the copy
Note: If you copy to another location, all cells below the extract range will be cleared when the
Advanced Filter is applied.
7. Click OK
97
98
99
Criteria on different rows are joined with an OR operator. In the second example at right -
By using multiple rows, you can combine the AND and OR operators. In the third example at right -
The * wildcard
The asterisk (*) wildcard character represents any number of characters in that position,
including zero characters.
In this example, any customer whose name contains "mart" will pass through the Excel advanced
filter.
The ? wildcard
The question mark (?) wildcard character represents one characters in that position.
In this example any 4-letter product that begins with c, and ends with ke, will pass through the Excel
advanced filter. Both Coke and Cake are in the filtered results.
The ~ wildcard
The tilde (~) wildcard character lets you search for characters that are used as wildcards.
In the first example at right, an asterisk is in the criteria cell -- Good*Eats -- so any products that begins
with Good and ends with Eats, will pass through the Excel advanced filter.
To find only the product that is named Good*Eats, use a tilde character in front of the asterisk in the
critereia cell. -- Good~*Eats.
101
102
103
Conditional Formatting
Data Validation
Pivot Tables
AutoFilters and Advanced Filters
If you use those built-in features, you might not need a macro. For example, instead of checking each cell in
a column, and manually coloring the cell green if it's over 50, use conditional formatting to highlight the
cells automatically.
Instead of doing that task manually every day, you could automate it, by creating an Excel macro.
104
Do you want the macro to open a specific workbook, or will that workbook already be open?
Should you select a cell or worksheet before the macro runs, or will selecting the cell be part of the
macro?
In this example, you want the macro to open the Orders workbook for you, and then filter and copy the
data. So, the Orders workbook should be closed when you start recording. You don't need to select a
specific cell or worksheet before recording; any cell selection will be done during the macro recording.
Start Recording
Once everything is in position, you can get ready to start recording.
1. Open a new blank workbook, which is where you'll store the macro.
2. At the bottom left of the Excel window, click the Record Macro button.
3. In the Record Macro dialog box, type a one word name for the macro, CopyDailyRecords
4. From the Store Macro In drop down, select This Workbook as the workbook where you'd like to
store the VBA code. Later, you can open this workbook every morning, to run the macro.
105
5. In the Description box, you can type a brief note about what the macro will do. This is optional, and
you can leave the Description box empty, if you prefer.
If you make a mistake - no problem! Just stop the recording (instructions below), close the files without
saving, and start over again.
Stop the Recording
Once you finished all the steps, follow these steps to turn off the Macro Recorder and save the macro file.
1. Click the Stop Recording button at the bottom left of the Excel window.
2. Close the workbook where you pasted the binder orders, without saving the changes.
3. Close the Orders.xlsx workbook, without saving the changes
4. Save the workbook where you stored the macro:
o Name: BinderCode.xlsm
o File Type: Excel Macro-Enabled Workbook *.xlsm
5. Close the BinderCode.xlsm file.
Get Ready to Test the Macro
To prepare to test the macro, make sure that the Orders.xlsx workbook is closed.
Add the Developer Tab
To run the macro, you'll use the Developer tab on the Excel Ribbon. You can add the Developer tab to the
Excel Ribbon, if it's not there already.
To add the Developer tab in Excel 2010:
1. Right-click on the Ribbon, and click Customize Ribbon
2. Add a check mark beside Developer, in the list at the right.
3. Click OK, to close the Excel Options window.
To add the Developer tab in Excel 2007:
1. Click the Microsoft Office Button, and then click Excel Options.
2. Click the Popular category, and add a check mark to Show Developer tab in the Ribbon
107
On the Ribbon, click the Developer tab, and in the Code group, click Macro Security.
In the Macro Settings category, under Macro Settings, click Disable all macros with notification
Click OK.
If you changed the setting, close the workbook, and then reopen it.
3. Click Enable This Content, to allow the workbook's macros to run, and click OK.
108
2. In the Macro dialog box, click the macro that you want to run - CopyDailyRecords.
3. Click Run.
If you see an error message, click the End button, and try recording the macro again. If everything went as
expected, great! You can close all 3 workbooks used by the macro, without saving the changes.
109