ppt - U of L Class Index

Computer Science 1000
Spreadsheets V
Permission to redistribute or use these slides is strictly prohibited without permission

Named Cell/Range

up until now:



cells were identified by Column-Row label
ranges were identified by top-left to bottom-right cells
sometimes, this is not intuitive


for example, the tax rate from our example was stored in
H1
we have to remember that location

easy on a small page, but imagine a page that is full of
information

Named Cell/Range



Excel offers the ability to apply a meaningful name
to a cell or range
this name can be used in place of the cell’s typical
label
procedure:


select the cell or range you wish to name
type the name into the Name box – left of the formula bar

Named Range

notice that renaming this cell does not affect the
current formulas

in other words, the standard cell labels still apply

Named Range

we can use the new label in place of the old cell
label

functions like an absolute reference

Named Range

to remove a name from a cell or range


select the Name Manager on the Formulas ribbon
select the name you wish to remove, and click Delete

Hiding Cells

the example is looking good, with one exception


the tax rate looks a little out of place
it would be nice if it was usable, but not visible

Hiding Cells


fortunately, Excel easily allows us to hide rows and columns
procedure:


select the rows or columns that you wish to hide by clicking on
Notice that Column G and H
their label
have disappeared. But the tax
right click, and select Hide
rate is still being applied.

Hiding Cells

to make a row or column visible again


select the rows/columns on either side
right click, and select Unhide
And they’re back!

Cross-sheet References


hidden cells work really nicely for computed cells
for cells that you have to change often, hidden cells
can be a pain


every time you need to make a change, you have to
unhide, and then remember to hide again when you are
complete
in these circumstances, it’s probably better to move
unneeded information to a new sheet

Cross-sheet References





most spreadsheets are stored as a workbook
each workbook has multiple worksheets, or sheets
each sheet represents the grid that you’ve seen so
far, but there are others
you can see the others by clicking on the tabs at
the bottom of your workbook
you can also add a new sheet by clicking on the
rightmost tab
Click here for new sheet.

Cross-sheet References


a formula in one sheet can reference a cell or range
from another sheet
to do this, simply prepend the name of the
reference with:



the name of the sheet (found on the tab)
the ! operator (often called the bang operator)
example: redo our previous example, but put the
tax information on Sheet4

Step 1: Put the tax information on the
new sheet

Step 2: Change the reference in the top formula

if your sheet name contains spaces, put it in single quotes

Step 3: Fill the other cells

same absolute/relative rules apply, so be careful!

Step 4: Delete the other tax information

not needed any longer

Sheet Names

thus far, our sheets have used their default names




this is ok, but like row/column labels, can be unintuitive
instead of accepting default sheet names, you can rename
each sheet to something more meaningful
procedure:



Sheet1, Sheet2, Sheet3
double click on sheet tab
type in the new name of the sheet
e.g. in our previous example, rename the sheet storing the tax
information to TaxInfo
Double
Click
Type
“TaxInfo”
Press
Enter

Sheet Names

when referencing, we can substitute the default
sheet name with the new sheet name

Sheet Names

rules



must be 31 or fewer characters
cannot contain [ ] * ? / \
quick note

if your sheet name contains a space, put it in single quotes
when referencing

Cross-sheet References and Named Cells



note that a named cell refers to a specific
row/column in a particular sheet
therefore, by naming a cell in a sheet, that cell can
be accessed by name in any other sheet, without
having to include a sheet reference
as an example, let’s modify our receipt example to
use the name TaxRate again, but from the Tax Info
sheet
Notice that TaxRate
is not qualified by a
sheet name.

Indirect Referencing

cell/range references allow us to directly specify
from which cell to grab a value


spreadsheets also allow indirect referencing


=B6 (takes value from B6)
the value from one cell allow us to reference a value from
a different cell
example formulas:


vlookup (vertical lookup)
hlookup (horizontal lookup)

VLOOKUP – Vertical Lookup


Searches for a value in the first column of a table
array and returns a value in the same row from
another column in the table array.
syntax:
 =VLOOKUP( value, table, column, type)




value – the value to find in the left column of table
table – a range of cells
column – the column to obtain the new value from
type – FALSE for an exact search, TRUE otherwise

VLOOKUP – The Basic Idea (Exact Search)

like a normal cell reference, you are basically
specifying a row and column


the column is the third input to the formula
the row is found via a match with the first input
Year
1989
1990
1991
1992
1993
City
Calgary
Edmonton
Pittsburgh
Pittsburgh
Montreal
Team
Flames
Oilers
Penguins
Penguins
Canadiens

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the city that won the
Stanley Cup in 1991


the value to look for would be 1991, hence the third row
the column is the 2nd column (2)
Year
1989
1990
1991
1992
1993
City
Calgary
Edmonton
Pittsburgh
Pittsburgh
Montreal
Team
Flames
Oilers
Penguins
Penguins
Canadiens

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the team that won the
Stanley Cup in 1989


the value to look for would be 1989 (first row)
the column is the 3rd column
Year
1989
1990
1991
1992
1993
City
Calgary
Edmonton
Pittsburgh
Pittsburgh
Montreal
Team
Flames
Oilers
Penguins
Penguins
Canadiens

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the city that won the Stanley Cup in 1994





recall formula: VLOOKUP( value, table, column, type)
first input: the value to find in the first column
second input: the table (a range)
third input: the column to get value from
fourth input: FALSE (since this is an exact search)

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the team that won the Stanley Cup in 1999





recall formula: VLOOKUP( value, table, column, type)
first input: the value to find in the first column
second input: the table (a range)
third input: the column to get value from
fourth input: FALSE (since this is an exact search)

VLOOKUP – Copy and Fill

often, VLOOKUP is used in multiple searches




e.g. your assignment, you must find a letter grade for each
student
since VLOOKUP is a formula, it can be used in a
copy and fill, like any other formula
however, caution must be used
e.g. modify our previous example, but find the Cup
winners for 2003, 1998, and 1989

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the teams that won the Stanley Cup in 2003,
1998, and 1989
What if we use Fill to
input the other values?

VLOOKUP – The Basic Idea (Exact Search)

suppose you want to find the teams that won the Stanley Cup in 1994,
1998, and 2003


because the table is specified using relative references, the starting and ending row
updates as we fill down
therefore, the formula in F4 specifies a table from A4 to C18, which excludes the
1989 row

VLOOKUP – The Basic Idea (Exact Search)


in almost all cases of VLOOKUP, the table is specified
using absolute references
this way, the table stays the same for all lookups

VLOOKUP – Approximate Search


suppose you have the following table
of data
you want to add a column called
generation





1946-1965: Baby boomers
1965-1979: Generation X
1980-1994: Generation Y
1995-2013: Generation Z
how many rows would be required for
a vlookup table?


1946, 1947, 1948, 1949, ....
68 rows
http://www.scribd.com/doc/27999012/Generations-defined

Vlookup – Approximate Search

fortunately, VLOOKUP allows us to do an
approximate search

simply change the last parameter to TRUE, or
omit it
when an approximate search is used, an
exact match is still attempted
 if an exact match is not found, then the next
largest value is matched


Example (approximate search):
suppose our lookup value is 1965
 since an exact match is found, it functions
the same as the exact VLOOKUP

Year Started Gen
1946
Baby Boomer
1965
Generation X
1980
Generation Y
1995
Generation Z

Example (approximate search):
suppose our lookup value is 1981
 since an exact match is not found, it finds
the next largest value that does match

Year Started Gen
1946
Baby Boomer
1965
Generation X
1980
Generation Y
1995
Generation Z

VLOOKUP – Approximate Search

VLOOKUP – Approximate Search

after filling

VLOOKUP – Approximate Search

note the result if we had used an exact
search

VLOOKUP – Two Last Points

1) lookup tables are often placed in a separate sheet


e.g. Assignment #3
like previous cell references, be sure to prepend table range
with the name of the sheet, separated by the bang (!) operator

VLOOKUP – Two Last Points

2) an analogous method called HLOOKUP exists that
performs similarly to VLOOKUP, but:


matches a column based on lookup value
row is specified