Sie sind auf Seite 1von 68

STUDENT MANUAL

Excel 2013:
PivotTables and
Macros
Towson University
Office of Technology Services
OTS Training



Excel 2013:
PivotTables and
Macros
Excel 2013: PivotTables and Macros
Part Number: 222784
Course Edition: 1.0
Acknowledgements
PROJECT TEAM
Author Media Designer Content Editor
Pamela J. Taylor Alex Tong Angie French
Notices
DISCLAIMER
While Logical Operations, Inc. takes care to ensure the accuracy and quality of these materials, we cannot guarantee their
accuracy, and all materials are provided without any warranty whatsoever, including, but not limited to, the implied warranties of
merchantability or fitness for a particular purpose. The name used in the data files for this course is that of a fictitious company. Any
resemblance to current or future companies is purely coincidental. We do not believe we have used anyone's name in creating this
course, but if we have, please notify us and we will change the name in the next revision of the course. Logical Operations is an
independent provider of integrated training solutions for individuals, businesses, educational institutions, and government agencies.
Use of screenshots, photographs of another entity's products, or another entity's product name or service in this book is for editorial
purposes only. No such use should be construed to imply sponsorship or endorsement of the book by, nor any affiliation of such
entity with Logical Operations. This courseware may contain links to sites on the internet that are owned and operated by third
parties (the "External Sites"). Logical Operations is not responsible for the availability of, or the content located on or through, any
External Site. Please contact Logical Operations if you have any concerns regarding such links or External Sites.
TRADEMARK NOTICES
Logical Operations and the Logical Operations logo are trademarks of Logical Operations, Inc. and its affiliates.
Microsoft

Office Excel

2010 is a registered trademark of Microsoft Corporation in the U.S. and other countries. Microsoft

Office
Outlook

and Microsoft

SharePoint

are also registered trademarks of Microsoft Corporation in the U.S. and other countries. The
other Microsoft products and services discussed or described may be trademarks or registered trademarks of Microsoft Corporation.
All other product and service names used may be common law or registered trademarks of their respective proprietors.
Copyright

2012 Logical Operations, Inc. All rights reserved. Screenshots used for illustrative purposes are the property of the
software proprietor. This publication, or any part thereof, may not be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, storage in an information retrieval system, or otherwise, without
express written permission of Logical Operations, 500 Canal View Boulevard, Rochester, NY 14623, (800) 456-4677. Logical
Operations World Wide Web site is located at www.logicaloperations.com.
This book conveys no rights in the software or other products about which it was written; all use or licensing of such software or
other products is the responsibility of the user according to terms and conditions of the owner. Do not make illegal copies of books
or software. If you believe that this book, related materials, or any other Logical Operations materials are being reproduced or
transmitted without permission, please call (800) 456-4677.
Excel 2013: PivotTables
and Macros
Analyzing Data with PivotTables, Slicers, and PivotCharts ............. 1
Create a PivotTable........................................................................ 2
Filter Data by Using Slicers........................................................... 16
Analyze Data by Using PivotCharts............................................... 23
Automating Worksheet Functionality .......................................... 29
Update Workbook Properties........................................................ 30
Create and Edit a Macro............................................................... 37
Apply Conditional Formatting....................................................... 48
Add Data Validation Criteria......................................................... 54
Lesson Labs.................................................................................61
Solutions..................................................................................... 63
Glossary...................................................................................... 65
Index...........................................................................................69
Analyzing Data with
PivotTables, Slicers, and
PivotCharts
Lesson Time: 1 hour
Lesson Objectives
In this lesson, you will:
Create a PivotTable.
Filter data by using slicers.
Analyze data by using PivotCharts.
Lesson Introduction
Excel has a variety of ways to store and view data. You've already built tables and charts.
Now you're ready to view your data in entirely new ways.
In this lesson, you will analyze data by using PivotTables, slicers, and PivotCharts.
TOPIC A
Create a PivotTable
Picture yourself standing on the corner of a busy intersection in the downtown area of a major city.
Cars are zooming by on the roads, large office buildings surround you, people hustle and bustle
about moving toward their various destinations.
You are facing north, looking up the large thoroughfare.
Now, imagine you don't move from where you are on the corner, you simply pivot to the left 90
degrees so that you are now facing west. Same city, same corner, same buildings and people, just a
slightly different perspective. Now you pivot to the left again, another 90 degrees. You're now facing
south. Again, it's still the same city and people and corner, just a slightly different view. The
buildings that were behind you when you were facing north are now right in front of you. What was
originally on your left is now on your right. One more 90 degree turn to the left and you're facing
east. Same story.
The city is your dataset. It is what it is. You are the PivotTable.
PivotTables
A PivotTable is a dynamic table that enables you to reposition the columns and rows of a raw dataset
without altering the data. The repositioned columns and rows provide new perspectives on the data.
PivotTables pivot columns into rows and rows into columns.
Consider the following two tables. The first table is the raw data table. The second table is a
PivotTable built from the dataset in the first table. Observe how, in the raw data table, Genre and
Market are both column headings.
Figure 1-1: A standard table.
2 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
The activities in this
lesson are written in a
continuous fashion.
Each new activity after
the first builds upon the
previous activity.
Consider teaching the
conceptual content by
keying through the
activities with the
students and teaching
the material as it comes
up in the activities.
Ask students, What do
you think PivotTables
do? Direct answers to
change your
perspective on the data.
A Standard Table
In the PivotTable, the genres have become the row headings, and each individual Market has
become a column heading.
This particular PivotTable shows you how many units of each genre have sold in each market. All of
that information is in the raw data, but it's a lot easier to find when you let a PivotTable find and
organize it for you.
Figure 1-2: A PivotTable.
The PivotTable does not change the raw data; it changes only your perspective on the data.
Start with Questions, End with Structure
To create PivotTables that will be useful for your business, begin by thinking of the types of
questions you'd like your raw data to answer. This is precisely the same type of questioning you
would do if you were creating functions and formulas.
The difference? Instead of using those questions to direct you to the types of functions you want to
include in a formula, you use those questions to help direct you to the structure of a table that will
provide you with the answers you're seeking.
So, a question like How many units of the Romance genre were sold in EMEA? reveals that you
need to count the number of units sold (the value you want to calculate) of a specific genre
(Romance) in a specific market (EMEA). This could lead you to a table that has Genres as rows and
Markets as columns. You could then scan across the Romance row, find where it intersects the
EMEA column, and locate your answer.
Or you might try positioning the Markets as rows and the Genres as columns.
The trick is to first think of the structure you want. Once you have that structure in mindor
sketched out on some scratch paperthen it's time to build the PivotTable that will provide you
with answers.
The PivotTable Fields Panel
With your PivotTable's structure in mind, you're ready to create your PivotTable. You do this by
using the PivotTable Fields panel.
This panel lists all of the fields in the dataset you've selected as the source data for your PivotTable.
Excel 2013: PivotTables and Macros | 3
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
A PivotTable
Refer students to the
previous figure.
Let students know that
PivotTables aren't a set
it and forget it kind of
operation. PivotTables
are designed to be
interactive, and students
should be actively using
and changing their
PivotTables as needed
to provide the
intelligence their
businesses need.
The PivotTable Fields
Panel
Figure 1-3: The PivotTable Fields panel.
You drag fields from the Choose fields to add to report section to where you want them to appear
in the PivotTable. In this example, Genre was dragged into the ROWS area because the genres will
appear as the row headings, and Market was dragged into the COLUMNS area because the
markets will appear as the column headings. Total Units to Date will be dragged to the VALUES
area because Total Units is the value you want to calculate. Excel defaults to SUM; however, there
are several other mathematical and statistical functions you can apply to the VALUES area.
4 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Note: To further explore the PivotTable Fields panel, you can access the LearnTO Add a
Report Filter to an Excel PivotTable presentation from the LearnTO tile on the
LogicalCHOICE Course screen.
Summarize Data in a PivotTable
Using the Summarize Values By options, you can summarize the data in a PivotTable by using a
variety of functions.
Figure 1-4: The Summarize Values By options.
The functions available here work the same way these functions work elsewhere in Excel. For
example, if you select Min, the PivotTable will return the minimum value. In this example, the
author who has sold the least number of total units in APAC is the author who has sold 1417 units.
Figure 1-5: Summarizing values by using the MIN function.
The Show Values As Functionality of a PivotTable
In addition to selecting how you want to summarize the data in a PivotTable, you can also select
how you want to show the values. When set to No Calculation, the values will appear by using
only the summary function you select from the Summarize Values By options.
Excel 2013: PivotTables and Macros | 5
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
You may want to show
LearnTO Add a Report
Filter to an Excel
PivotTable from the
LogicalCHOICE Course
screen or have students
navigate out to the
Course screen and
watch it themselves as a
supplement to your
instruction. If not, please
remind students to visit
the LearnTOs for this
course on their
LogicalCHOICE Course
screen after class for
supplemental
information and
additional resources.
The Summarize Values
By Options
Ask students, What do
you notice about the
Grand Totals? Direct
answers to, In this MIN
example, the Grand
Totals identify the lowest
value in the column or
row. Then ask, What
do you suppose the
Grant Totals would show
if you summarized by
Average? Direct
answers to, The
average value of the row
or column.
Summarizing Values by
Using the MIN Function
The Show Values As
Options
Figure 1-6: The Show Values As options.
In this example, Show Values As has been set to % of Grand Total.
6 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Figure 1-7: Showing Values as a percent of the grand total.
Combine Summarize and Show
Combining Summarize Values By and Show Values As options enables you to deepen your
understanding of your data. Here is one simple example to illustrate this point.
This PivotTable is summarizing values by Max and showing values as a rank from largest to smallest
by market. In other words, this PivotTable addresses the question, How do the markets rank by
maximum number of units sold of a single title per genre? In this case, APAC ranks first for
Fantasy. This means that of all the books sold in either print or electronic format, the market that
has purchased the most units of a single Fantasy title is APAC.
Figure 1-8: Combining summarize and show (Example 1).
However, look what happens when you change Summarize Values By to Count but keep Show
Values As at Rank Largest to Smallest. In this case, the PivotTable is answering the question,
How do the markets rank by total number of titles sold in each genre? APAC is now ranked
second by this criterion.
Excel 2013: PivotTables and Macros | 7
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Ask students, What do
you notice about the
values and the Grand
Totals? Direct answers
to, Each value is
displayed as a percent
of the Grand Total, and
each row and column
sums to a percentage of
the Grand Total.
Showing Values As a
Percent of the Grand
Total
Combining Summarize
and Show (Example 1)
Combining Summarize
and Show (Example 2)
Figure 1-9: Combining summarize and show (Example 2).
PowerPivot
PowerPivot is an Excel add-in that simplifies business intelligence data analysis for organizations
that have massive datasets dispersed across multiple data sources. When you're working with
hundreds of millions of records, Excel's default specifications for rowsjust over 1,000,000 rows
won't provide the space you need. PowerPivot addresses precisely this challenge and empowers you
to link multiple data sources in a single interfaceExcel 2013and run analysis on datasets that
stretch into the hundreds of millions of rows.
To learn more about PowerPivot and download this free add-in, visit www.microsoft.com/en-
us/bi/powerpivot.aspx.
PowerPivot Functions
Data Analysis Expressions (DAX) functions are used to define calculations in PowerPivot. DAX
provides a variety of functions that perform calculations using PowerPivot data, The following table
describes the most common ones.
Function Description
RIGHT Returns the last character or characters in a text string, based
on the number of characters specified.
LEFT Returns the specified number of characters from the start of a
text string.
MID Returns a string of characters from the middle of a text string,
given a starting position and length.
TRIM Removes all spaces from text except for single spaces between
words.
UPPER Converts text to uppercase.
LOWER Converts all uppercase letters in a text string to lower case.
CONCATENATE Joins two text strings into one text string.
External Data
In a perfect world, all of your data would live in external data sources. For example, you might have
an HR database, a sales database, an inventory database, and a call center database. Depending on
the size of your business, this might even be a requirement.
8 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Ask students, What do
you notice about this
PivotTable? Direct
answers to the fact that
the Romance genre
does not have a number
four ranking and the
Thriller genre does not
have a number three or
four ranking. Then ask
them, What does this
tell you about the data?
Direct answers to, For
Romance, the total
number of titles sold is
the same in APAC and
EMEA, and for the
Thriller genre, the total
number of titles sold in
EMEA, LA, and NA is
also the same. Then
ask them, How can you
verify this? and direct
answers to Keep
Summarize Values By at
Count but change Show
Values As to No
Calculation. That would
reveal the actual count
of titles sold in each
market for each genre.
Rather than export data from those sources and store it in Excel, a more efficient method is to
connect Excel directly to those external sources. If you store data in Excel and in the external data
sources, you run the serious risk of the data in Excel not being up-to-date.
The biggest benefit of connecting to external data sources is the accuracy of the data: your data will
always be up-to-date. Which is precisely what you want for making business decisions.
PowerPivot is one of the tools that makes it very easy for you to connect to external data sources.
However, Excel has many other built-in tools to make the connections to and management of
external connections easy.
For more information on how to connect to and manage external data, search for external data in
the Excel 2013 Help system.
How to Create a PivotTable
Use this procedure to create a PivotTable.
Note: Access the Checklist tile in the LogicalCHOICE Course screen to view all How To
procedures for this lesson.
Create a PivotTable
To create a PivotTable:
1. Identify a few key questions you'd like the PivotTable to be able to answer about your data.
2. On scratch paper, sketch out the structure you'd like the PivotTable to take. Which fields from
the source data will be the rows? Which fields will be the columns? On which field do you want
to run the calculations?
3. In Excel 2013, select INSERTTablesPivotTable.
4. In the Create PivotTable dialog box, select the data you want to analyze.
If the data is in the current workbook, select the Select a table or range radio button, and
then select the Collapse Dialog button and select the table or range.
If the data is in an external source, select the Use an external data source radio button, and
then select the data source.
5. In the Create PivotTable dialog box, choose whether you want to add the PivotTable to a New
Worksheet or to an Existing Worksheet.
6. Select OK.
7. In the PivotTable Fields panel, using the structure you sketched out on scratch paper as a
guide, from the Choose fields to add to report list, drag the fields that will be rows to the
ROWS area, the fields that will be columns to the COLUMNS area, and the fields on which
you want to run calculations to the VALUES area.
8. If necessary, drag fields to the FILTERS field. Note: FILTERS in a PivotTable work in the
same way as the Sort functionality on a standard table, enabling you to refine the PivotTable by
which ever criteria appears in the FILTERS field.
9. On the worksheet, test your PivotTable.
10. As necessary, on the PivotTable, change the Summarize Values By and Show Values As
settings.
Excel 2013: PivotTables and Macros | 9
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
ACTIVITY 1-1
Creating PivotTables
Data Files
C:\091015Data\Analyzing Data with PivotTables, Slicers, and PivotCharts\Author_Data_05.xlsx
Before You Begin
Excel 2013 is open.
Scenario
Your data analysis and visualization needs continue to grow.
Two primary questions that continue to come up are:
What's the total number of units sold per genre in each market we serve?
For each author and book, what are the total sales of electronic books versus the total sales of
print books?
To answer these questions, you've decided to create two pivot tables, one that addresses the genres-
by-market question and one that addresses the sales of electronic versus print for authors and book
titles question.
1. Open the file Author_Data_05.xlsx.
2. Add a PivotTable that answers the primary question, What's the total number of units sold per genre in
each market we serve?
a) On the Sales Dashboard spreadsheet, select cell AP1.
b) Type pvtblGenresAndMarkets
c) Select cell AP2.
d) Select INSERTTablesPivotTable.
e) In the Table/Range field, type tblSalesData

10 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training

f) Verify that the location is cell AP2 and select OK.
g) In the PivotTable Fields panel, drag Genre from the Choose fields to add to report list to the ROWS
area.

Excel 2013: PivotTables and Macros | 11
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts

h) Drag Market from the Choose fields to add to report list to the COLUMNS area.
i) Drag Total Units to Date from the Choose fields to add to report list to the VALUES area.

12 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training

j) Select any cell in the PivotTable and then, on the PIVOTTABLE TOOLS ANALYZE tab, in the
PivotTable group, clear the contents of the PivotTable Name field and type pvtblGenresAndMarkets
k) Press Enter.
3. Use the PivotTable to answer the question, Which genre is our biggest overall seller?
a) Right-click cell AU4 and select SortSort Largest to Smallest.
4. Which genre is the biggest overall seller?
A: Romance is the biggest overall seller with 108893789 units sold.
5. Use the PivotTable to answer the question, For APAC and EMEA only, what is the combined number
of total units sold for Romance and Fantasy?
a) From the Column Labels drop-down list, uncheck the Select All check box, check APAC and EMEA,
and then select OK.
b) From the Row Labels drop-down list, uncheck the Select All check box, check Fantasy and
Romance, and then select OK.
6. What is the combined number of total units sold for Romance and Fantasy in APAC and EMEA?
A: The total units sold for Fantasy and Romance in APAC and EMEA is 63730961.
7. Use the PivotTable to answer the question, What percentage of total unit sales is made up of LAs
Fantasy genre sales?
a) Clear all filters from the rows and column label lists.
b) Right-click any of the data cells.
Excel 2013: PivotTables and Macros | 13
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Point out to students that
even a small PivotTable
can answer a huge array
of related granular
questions.
c) Select Show Values As% of Grand Total.
8. What percentage of total unit sales is LAs Fantasy genre sales?
A: Fantasy sales in LA account for 3.50% of total sales.
9. Use the PivotTable to answer the question, Which market has the highest percentage of SF sales?
a) Right-click any of the data cells.
b) Select Show Values As% of Row Total.
10. Which market has the highest percentage of SF sales?
A: NA has the highest percentage of SF sales at 26.67% of total SF sales.
11. Add a PivotTable that answers the primary question, For each author and book, what are the total
sales of electronic books versus the total sales of print books?
a) On the Sales Dashboard spreadsheet, select cell AP9.
b) Type pvtblAuthorsAndFormats
c) Select cell AP10.
d) Select INSERTTablesPivotTable.
e) In the Table/Range field, type tblSalesData
f) Verify that the location is cell AP10 and select OK.
g) In the PivotTable Fields panel, drag Author from the Choose fields to add to report list to the ROWS
area.
h) Drag Title from the Choose fields to add to report list to the ROWS area, making sure to drop it
below Author.
i) Drag Format from the Choose fields to add to report list to the COLUMNS area.
j) Drag Total Earnings to Date from the Choose fields to add to report list to the VALUES area.
k) Select any cell in the PivotTable and, on the PIVOTTABLE TOOLS ANALYZE tab, in the PivotTable
group, clear the contents of the PivotTable Name field and type pvtblAuthorsAndFormats
l) Press Enter.
m) In the PivotTable, right-click any of the data cells and select Value Field Settings.
n) In the Value Field Settings dialog box, select Number Format.
o) In the Format Cells dialog box, select Currency and then select OK twice.


12. Use the PivotTable to answer the question, Which author has the lowest total sales?
a) Right-click cell AS12 and select SortSort Smallest to Largest.
14 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Reinforce how small this
particular PivotTable is
and point out that you've
asked it only a few of the
many possible questions
it can answer.
Reinforce for students
that building PivotTables
takes hardly any time at
all as long as you know
what questions you want
your data to answer and
the basic layout of what
you want the PivotTable
to look like.
13. Which author has the lowest total sales?
A: Author 1011 is lowest with $1,434,234.24 in sales.
14. Use the PivotTable to answer the question, For author 1011, which book has the highest sales?
a) Right-click cell AS13 and select SortSort Largest to Smallest.
15. For author 1011, which book has the highest sales?
A: For author 1011 BookTitle0052 has the highest sales at $276,914.82.
16. Use the PivotTable to answer the question, What percentage of author 1048s total sales are electronic
books?
a) Select the Row Labels drop-down list.
b) In the Search box, type 1048
c) Press Enter.
d) Right-click cell AQ12, and then select Show Values As% of Row Total.
17. What percentage of author 1048s total sales are electronic books?
A: Electronic book sales account for 16.41% of author 1048s total sales.
18. Save your work as My_Author_Data_05.xlsx
Excel 2013: PivotTables and Macros | 15
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Ask students, What did
you notice about those
last two sorts? Direct
answers to: If you have
grouped rows and you
place the cursor in a
parent row (for example,
an author row in this
PivotTable), then the
entire dataset will sort
based on the parent
rows. If you click in a
child row of one of the
groups (for example, the
book titles) and then
sort, you'll sort within
each group.
TOPIC B
Filter Data by Using Slicers
Once you've created a PivotTable, you will want to make sorting and filtering the data in the table as
efficient as possible. Although you can use the functionality built directly into the PivotTable to find
the answers to your questions, there is another type of functionality that makes sorting and filtering
PivotTables easier: slicers.
Slicers
Slicers are filtering tools that filter PivotTable and PivotChart data based on user selections. Slicer
filtering functions in the exact same way as the filtering you're used to seeing on tables, but instead
of selecting filters from a list at the top of table columns, you select filter criteria by selecting
buttons in the slicers. Use the standard Ctrl+click procedure to select more than one non-
contiguous button and Shift+click to select more than one contiguous button.
One slicer can connect to multiple PivotTables and one PivotTable can connect to multiple slicers.
In this example, five slicers have been associated with the PivotTable. The slicers are based on the
fields in the source data.
This example answers questions such as, for all authors selling electronically formatted SF and
Thriller novels in APAC and NA only, what percentage of total unit sales is the Thriller genre in
NA? (The result is 11.67%.) What percentage of total unit sales is the SF genre in APAC? (The
result is 22.67%.) And, what percentage of total unit sales is the Thriller genre overall? (The result is
50.13%.)
Figure 1-10: Slicers and a PivotTable.
Note that you can select slicers from the source data that don't appear as rows or columns in the
PivotTable. Because the slicers and PivotTable come from the same data source, the slicers will filter
the PivotTable accordingly. In the example, Format, Author, and Title are not rows or columns in
the PivotTable. However, when you include the slicers for those fields and select the criteria, the
PivotTable adds those criteria to its filter.
How to Add Slicers to a PivotTable
Use these procedures to add slicers to a PivotTable and connect slicers to more than one
PivotTable.
16 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Slicers and a PivotTable
Add Slicers to a PivotTable
To add slicers to a PivotTable:
1. Select any cell in the PivotTable.
2. Select PIVOTTABLE TOOLS ANALYZEFilterInsert Slicer.
3. In the Insert Slicers dialog box, check all of the fields on which you would like to filter.
4. Select OK.
5. Position the slicer(s) on the worksheet.
Connect Slicers to More than One PivotTable
To connect slicers to more than one PivotTable:
1. Select any cell in the PivotTable you would like to connect to existing slicers.
2. Select PIVOTTABLE TOOLS ANALYZEFilterFilter Connections.
3. In the Filter Connections dialog box, check all of the Slicers that you want to associate with
the PivotTable you have selected on the worksheet. Note: In order to connect a PivotTable to
existing slicers, the PivotTable must be based on precisely the same range as the PivotTable used
to create the slicers.
4. Select OK.
Set Slicer Size and Properties
To set the size and properties of a slicer:
1. Right-click the slicer and select Size and Properties.
2. In the Format Slicer panel, set the size and properties as needed.
Excel 2013: PivotTables and Macros | 17
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
ACTIVITY 1-2
Adding Slicers
Before You Begin
My_Author_Data_05.xlsx is open.
Scenario
To make it easier to filter data in your PivotTables, you've decided to incorporate slicers into the
Sales Dashboard worksheet.
Rather than add separate sets of slicers to each PivotTable, you plan to add one set of slicers and
then connect the slicers to the appropriate PivotTables.
1. In My_Author_Data_05.xlsx, add slicers that will enable you to sort and filter the
pvtblGenresAndMarkets PivotTable by author, title, genre, market, and format.
a) Select any cell in the pvtblGenresAndMarkets PivotTable, and then select PIVOTTABLE TOOLS
ANALYZEFilterInsert Slicer.


b) In the Insert Slicers dialog box, check Author, Title, Genre, Format, and Market, and then select OK.

18 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training

c) Position the slicers to the right of the genre-by-market table.


2. Use the slicers to answer the question, How many Romance print books has author 1029 sold in
APAC?
a) On the Genre slicer, select Romance.
b) On the Market slicer, select APAC.
Excel 2013: PivotTables and Macros | 19
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Inform students that the
position of their slicers
doesn't exactly have to
match the position in the
screen capture. The idea
is to move them to the
right and be prepared to
position them so they
don't overlap each other
or the PivotTables. They
should get in the habit of
constantly moving stuff
around on their
worksheet until the
worksheet is in a
finished or near-finished
state.
c) On the Format slicer, select Print.
d) On the Author slicer, select 1029.
3. How many Romance print books has author 1029 sold in APAC?
A: Author 1029 has sold 252061 print Romance books in APAC.
4. Use the slicers to answer the question, Of author 1056s NA electronic sales for Fantasy and SF, what
percentage is SF?
a) Right-click any data cell in the pvtblGenresAndMarkets PivotTable and select Show Values As% of
Column Total.
b) Select the Clear Filter button on each Slicer.
c) On the Genre Slicer, select Fantasy, press and hold Ctrl, and then select SF.
d) One the Market slicer, select NA.
e) On the Format slicer, select Electronic.
f) On the Author slicer, select 1056.
5. Of author 1056s NA electronic sales for Fantasy and SF, what percentage is SF?
A: Electronic sales of SF books account for 31.42% of author 1056s total NA electronic sales.
6. Adjust the slicer connections for both PivotTables.
a) Select any cell in pvtblGenresAndMarkets PivotTable, and then on the PIVOTTABLE TOOLS
ANALYZE tab, in the Filter select Filter Connections.
b) In the Slicer Connections dialog box, uncheck Title.


c) Select OK.
d) Select any cell in pvtblAuthorsAndFormats, and then, on the PIVOTTABLE TOOLS ANALYZE tab,
in the Filter select Filter Connections.
e) In the Filter Connections dialog box, check the box for every slicer.

20 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Students might get stuck
here because right now,
the
pvtblGenresAndMarkets
PivotTable is displaying
a percentage rather than
the sum of total unit
sales. Ask them to
troubleshoot this issue
on their own. Direct
them to really think
through what they want
the table to display. In
this case, they want to
know the total number of
books sold, not the total
number of titles in print,
so they'll need to right-
click the table and select
Show Values AsNo
Calculation.
Check in with students
to assess their progress
up to this point.

f) Select OK.
7. Position the slicers beneath the Forecast chart.


8. Prevent the slicers from resizing or moving with cells.
a) Ctrl+click each slicer to select them all at once.
Excel 2013: PivotTables and Macros | 21
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Inform students that they
are moving the slicers to
this position to practice
positioning and setting
the properties of slicers
and also to set the
worksheet up for the
next activity. Direct them
to Ctrl+click each slicer,
and then use the
Arrange tools on the
Slicer Tools Options tab
to align the slicers at the
top and distribute them
horizontally.
b) Right-click and select Size and Properties.
c) In the Format Slicer task pane, expand Properties.
d) Select Don't move or size with cells.
9. Save your work.
22 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
TOPIC C
Analyze Data by Using PivotCharts
You've created tables and PivotTables, and you're familiar with the difference between the two.
You've also created charts. Now, you'd like to leverage the flexibility of PivotTable filtering in your
charts. That's where PivotCharts come in.
PivotCharts
PivotCharts are interactive charts that allow you to filter data on the fly by selecting filter data either
directly on the chart or via slicers that have been connected to the chart.
The PivotChart in this example answers the question, Regardless of format, which Fantasy title of
Author 1005 is selling the best in LA? The answer is BookTitle0003 with just over 8,000 units sold.
Figure 1-11: Slicers and a PivotChart.
Similar to a PivotTable, once you connect slicers to a PivotChart, you can filter the data by using
either the slicers or the lists directly on the chart. Whichever you use, the other will reflect the filter.
For example, if you select LA in the slicer, only LA will be selected in the Genre list on the chart.
How to Insert a PivotChart
Use this procedure to insert a PivotChart.
Insert a PivotChart
To insert a PivotChart:
1. Select any cell in the desired PivotTable. Note: You can also create a PivotChart using a data
range.
2. Select PIVOTTABLE TOOLS ANALYZEToolsPivotChart.
3. In the Insert Chart dialog box, select the type of chart you want to insert.
Excel 2013: PivotTables and Macros | 23
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Slicers and a PivotChart
4. Select OK.
5. Position the chart on the worksheet and format as needed.
6. Filter the chart as needed.
24 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
ACTIVITY 1-3
Creating a PivotChart
Before You Begin
My_Author_Data_05.xlsx is open.
Scenario
To further enhance the workbook, you've decided to add a PivotChart to the Sales Dashboard. This
PivotChart will be controlled by the same slicers that currently control the two PivotTables that
already exist on the Sales Dashboard.
1. In My_Author_Data_05.xlsx, create a PivotChart based on the PivotTable named
pvtblGenresAndMarkets
a) Right-click any cell in pvtblGenresAndMarkets and select Show Values AsNo Calculation.
b) Select PIVOTTABLE TOOLS ANALYZEToolsPivotChart.
c) In the Insert Chart dialog box, in the left pane, select Column, and then, at the top of the right pane,
select Clustered Column.
d) Select OK.
e) Position the new PivotChart so it is below the slicers.


f) On the slicers, clear all filters.
2. Using the slicers and PivotChart, answer the questions, Does author 1008 have any books in the LA
market? If so, which book is author 1008s biggest seller in that market, what format is the book selling
in, and how many units has it sold?
a) Ensure all of the filters from all of the slicers have been cleared.
b) On the Market slicer, select LA.
c) On the Format slicer, select Electronic.
Excel 2013: PivotTables and Macros | 25
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Ask students, What do
you notice about the
data in the PivotChart?
Direct answers to,
Romance in NA is
clearly the dominant
genre/market pair. Call
attention to the fact that
charts enable immediate
understanding through
visual and quantitative
displays (not just
quantitative).
d) On the Author slicer, select 1008.
e) Observe the Title slicer. How many books did author 1008 publish?
f) On the chart, right-click the Fantasy data series, and then select Expand/CollapseExpand Entire
Field.
g) In the Show Detail dialog box, select Title.
h) Select OK.
i) In the Microsoft Excel dialog box, select OK.
3. Which book is author 1008s biggest seller in the LA market, what format is the book selling in, and how
many units has it sold?
A: BookTitle0039 is author 1008s biggest seller in the LA market with 252558 units sold. It's in the
Fantasy genre and is an electronic book.
4. Save and close your work.
26 | Excel 2013: PivotTables and Macros
Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts OTS Training
Point out to students that
the slicers are already
directing them toward
their answer, even
before they make further
adjustments on the
chart. With author 1008
and LA selected, the
Title slicer shows only
two titles available, the
Genre slicer shows only
two genres available,
and the Format slicer
shows only Electronic
available. So we already
know at this point,
without even looking at
the chart, that author
1008 has two electronic
fantasy and/or thriller
books published in the
LA market. Additionally,
a glance at the chart
tells us that this author is
selling a lot more fantasy
than thriller in the LA
market.
Point out that we know
this is an electronic book
because only the
Electronic format is
selected in the slicers.
Time permitting, ask
students, What other
questions would you like
to ask of the data?
Encourage them to
come up with their own
questions and use the
slicers and PivotChart to
find the answers.
Summary
In this lesson, you created PivotTables and PivotCharts and discovered the power they give you
when you want to view your data in new and, perhaps, unexpected ways.
You also learned about slicers. Slicers make it easy to select the data you want to filter and view in
your PivotTables and PivotCharts.
PivotTables, PivotCharts, and slicers make data visualization interactive. When data is interactive,
data users begin to engage the data more deeply, uncovering new questions and answers that might
not be readily apparent if the data were presented in a static format.
Consider the types of data your firm generates. What kinds of questions would you like to ask the data?
A: Answers will vary, but consider the various types of data your firm generates in the context of how
PivotTables, PivotCharts, and/or slicers could help you answer questions about your business. These
tools enable you to ask virtually anything of your data, but you will want to make sure that you are
asking questions from a business perspective and not strictly a data analysis perspective.
How could you leverage PivotTables, PivotCharts, and slicers to create interactive dashboards that will help
you uncover new knowledge about your business?
A: Answers will vary, but remember that Excel tools help you quickly find both granular data and trends in
data.
Note: Check your LogicalCHOICE Course screen for opportunities to interact with your
classmates, peers, and the larger LogicalCHOICE online community about the topics covered in
this course or other topics you are interested in. From the Course screen, you can also access
available resources for a more continuous learning experience.
Excel 2013: PivotTables and Macros | 27
Towson University Lesson 1: Analyzing Data with PivotTables, Slicers, and PivotCharts
Encourage students to
use the social
networking tools
provided on the
LogicalCHOICE Home
screen to follow up with
their peers after the
course is completed for
further discussion and
resources to support
continued learning.
Automating Worksheet
Functionality
Lesson Time: 1 hour, 15 minutes
Lesson Objectives
In this lesson, you will:
Update workbook properties.
Create and edit a macro.
Use conditional formatting.
Add data validation criteria.
Lesson Introduction
From your prior training, you already know the basic functionality of Microsoft

Excel

. As
your projects and worksheets become more complex, you will want ways of streamlining
your projects. Excel offers a number of tools that let you automate your work process. Your
ability to automate will let you work more efficiently and accurately.
TOPIC A
Update Workbook Properties
In Excel 2013, you can use the Document panel to add or change the properties of a workbook.
You can enter information that relates to a workbook such as the author, title, keywords, status, and
comments. This information is sometimes referred to as metadata. Other than being added to a
workbook, metadata can also be altered and deleted. The metadata you enter will help you better
manage and locate your workbook files. In this topic, you will update a workbook's properties.
Imagine that your boss needs some sales data from a worksheet for a presentation that she has to
give in a couple of hours. The problem is that with all the workbooks that you use on a daily basis,
you cannot find the right one. Obviously, telling her that you cannot find the numbers or making
something up is not an option. You wish there was some way to help you find the right information.
It can be extremely frustrating to search for something you need, especially when working under a
deadline. In this topic, you will learn how to update workbook properties to help you find and
identify files.
Workbook Properties
The Workbook Name Properties dialog box has five tabs for specifying properties.
Figure 2-1: Workbook properties.
30 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Workbook Properties
Tab Description
General The General tab shows the file name, type, location, size, MS-DOS
name, creation date, modification date, and access date. It also displays if
the file is read-only. These settings cannot be changed from the
Workbook Name Properties dialog box. This information is supplied by
the system.
Summary Allows you specify the file's title, subject, author, manager, company,
category, keywords, and hyperlink base.
Statistics Shows system information like creation date, last modified date, last
accessed date, and last printed date. It also shows the name of the
person who last saved the file, the revision number (when applicable),
and the total editing time. Data cannot be edited here.
Contents Shows the number of the worksheets by name. Data cannot be edited
here.
Custom Allows you to attach specific information to the file such as destination,
editor, language, and other traits. It is possible to add a property name of
your properties.
How to Update Workbook Properties
You can use these general steps to update workbook properties.
Note: All of the How To procedures for this lesson are available as checklists from the
Checklist tile on the LogicalCHOICE Course screen.
Update Workbook Properties
To update workbook properties:
1. In an open workbook, select FILEInfo.
2. On the Info screen, from the Properties drop-down list on the right side of the screen, select
Advanced Properties.
3. In the Workbook Name Properties dialog box, set the desired summary properties.
a. Select the Summary tab.
b. In the appropriate text box, enter the document information.
4. Set the desired custom properties.
a. Select the Custom tab.
b. In the Name text box, enter the desired name for a custom property, or select an option
from the Name text box menu.
c. From the Type drop-down list, select the desired option to limit the type of information that
can be entered for the property.
d. In the Value text box, type the value of the property. If you selected Yes or No from the
Type drop-down list, select either the Yes or the No radio button.
e. Select Add.
5. As desired, create additional custom properties.
6. Select OK to close the Workbook Name Properties dialog box.
7. Save the document to store the new properties in the file.
Update Workbook Properties in the Backstage View
To update workbook properties in the Backstage view:
Excel 2013: PivotTables and Macros | 31
Towson University Lesson 2: Automating Worksheet Functionality
1. In an open workbook, select FILEInfo.
2. On the Info screen, from the right side of the screen, edit the information related to the
workbook.
Select Add a title and type in the desired title.
Select Add a tag to add keywords that can be used to identify the workbook.
Select Add a category to categorize the workbook.
Select Add an author and type the name of the author.
3. Select Show All Properties to show all possible properties.
To add more comments, select Add comments.
In the Status field, select Add text and enter the workbook status.
In the Subject field, select Specify the subject and type a subject for the workbook.
In the Hyperlink Base field, select Add text and type the hyperlink base of the workbook.
To set a company name, in the Company field, select Specify the company and type in the
company's name.
4. Save the workbook.
Update Workbook Properties Using the Document Panel
To update workbook properties using the Document panel:
1. In an open workbook, select FILEInfo.
2. On the Info screen, from the right side of the screen, from the Properties drop-down list, select
Show Document Panel.
3. In the Document panel, enter information relating to the workbook.
Type the name of the author in the Author text box.
Type a title in the Title text box.
Type a subject in the Subject text box.
Type any desired tags in the Keywords text box.
Type a category in the Category text box.
Type the relevant status in the Status text box.
Type any comments in the Comments text box.
4. If you would like to edit advanced properties, from the Document Properties drop-down list,
select Advanced Properties.
5. Make the desired changes.
6. Close the Workbook Name Properties dialog box.
7. Close the Document panel.
8. Verify that the information is entered from the Info tab in the Backstage view.
Modify the Default Settings in Excel
To modify the default settings in Excel:
1. In an open workbook, select FILEOptions.
2. Make the necessary changes in the Excel Options dialog box.
On the General tab, in the When creating new workbooks section, select the Use this as
the default font down-arrow to change the font for all new workbooks.
Select the Font size down-arrow to change the font size for all new workbooks.
Select the Default view for new sheets down-arrow to change the default view for all new
workbooks.
Use the Include this many sheets spin buttons to change the default number of worksheets
in all new workbooks.
Select the Formulas tab to change the way formulas are evaluated.
Select the Save tab to change the save settings for all new workbooks.
Select the Language tab to change the language settings.
32 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Select the Proofing tab to change the proofing settings.
Select the Advanced tab to change the editing, cutting and pasting, copying, image size, print,
chart, and display settings.
Select the Customize ribbon tab to make customizations to the ribbon.
Select the Quick Access Toolbar tab to customize the Quick Access Toolbar.
Select the Add-Ins tab to activate or deactivate Excel add-ins.
Select the Trust Center tab to specify how Trust Center will work for all new workbooks.
3. In the Excel Options dialog box, select OK, and then in the Microsoft Excel warning box,
select OK again. This quits and then restarts Excel.
Change the Default File Storage Location
To modify the default file storage location:
1. Create a folder that you want to set as the default place for Excel to save files.
2. Open the Excel Options dialog box and select the Save tab.
3. In the Default local file location text box, enter the path to where you want to save files.
4. Select OK.
Excel 2013: PivotTables and Macros | 33
Towson University Lesson 2: Automating Worksheet Functionality
ACTIVITY 2-1
Updating Workbook Properties
Data Files
C:\091016Data\Automating Worksheet Functionality\Asian_Royalties.xlsx
Scenario
You work for Fuller & Ackerman Publishing and are managing a project to simplify the payment of
royalties to international authors. Last year there were a number of costly mistakes that took a long
time to resolve because out-of-date and incorrect workbooks were used to calculate payments. To
make sure that this never happens again, your boss wants you to go through all workbooks and
update their properties to make them easier to find and identify.
1. Navigate to the C:\091016Data\Automating Worksheet Functionality folder and open the Excel
worksheet Asian_Royalties.xlsx.
2. If prompted, in the message bar, select Enable Editing.
3. Access the file properties in the Backstage view.
a) Select the FILE tab.
b) From the Properties drop-down list at the right of the window, select Advanced Properties.
4. Update the file's properties.
a) Select the Summary tab.
b) In the Title text box, type Asian Royalties
c) In the Subject text box, type Asian Royalty Payments
d) In the Author text box, type Driscoll, Martin
e) In the Manager text box, type Kreugel, Hans
f) In the Company text box, type Fuller and Ackerman
g) In the Category text box, type Author Royalties
h) In the Keywords text box, type Asian Sales Royalties
i) In the Comments text box, type This file tracks author sales and the royalties they are due

34 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training

5. Select OK.
6. Save your workbook in the C:\091016Data\Automating Worksheet Functionality folder as
My_Asian_Royalties.xlsx
Excel 2013: PivotTables and Macros | 35
Towson University Lesson 2: Automating Worksheet Functionality
ACTIVITY 2-2
Modifying the Default Settings in Excel
Before You Begin
My_Asian_Royalties.xlsx is open.
Scenario
Your manager likes the changes that you made to file properties to make them easier to find. She
would like to build additional ways of identifying files so the problems that happened last year never
happen again. She suggests that all new files this year have a new font type and size, so that going
forward everyone will be able to easily tell when the files were created.
1. Set the default settings for Excel workbooks.
a) Select FILEOptions.
b) In the Excel Options dialog box, on the General tab, in the When creating new workbooks section,
from the Use this as the default font drop-down list, select Arial.
c) In the Font size drop-down list, change the font size from 11 to 12.


d) In the Excel Options dialog box, select OK.
e) In the Microsoft Excel warning box, select OK.
2. Save your work and close the Excel file.
3. Verify that the default setting for new documents is Arial 12 point.
a) Open a blank workbook.
b) Type something into a cell and verify that the default type is Arial 12 point.
c) Close the file without saving.
Note: Check out the LearnTO Protect a Worksheet in a Workbook presentation
from the LearnTO tile for this course on your LogicalCHOICE Course screen.
36 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
You may want to show
LearnTO Protect a
Worksheet in a
Workbook from the
LogicalCHOICE Course
screen, or have students
navigate out to the
Course screen and
watch it themselves as a
supplement to your
instruction. If not, please
remind students to visit
the LearnTOs for this
course on their
LogicalCHOICE Course
screen after class for
supplemental
information and
additional resources.
TOPIC B
Create and Edit a Macro
Doing the same thing over and over can get tedious and contribute to data errors and omissions.
However, your organization likely needs to run the same kind of analysis and have a common look
for many different files. Automating frequently used tasks lets you complete your work more
accurately and efficiently. In this topic, you will create and edit a macro. Macros automate complex
tasks to ensure repetitive precision.
Macros
A macro is an automated tool that repeats a set of commands to complete a series of frequently
needed tasks. Every macro must have a unique name. A macro-enabled workbook is saved with
the .xlsm extension. You can create a macro recorder to record the sequence of steps that you want
included in your macro, and then set a command to run the macro. The macro recorder converts
your macro into Visual Basic programming code that can be edited as required. Macros can be saved
in any workbook.
Excel can reference macros in two different ways. Absolute referencing means that you set specific
cells for the macro to work and the macro always uses those cells. Relative referencing means that
cells are specified based on their relationship with other cells (for example, four cells down).
Absolute referencing is the default.
Figure 2-2: The Macros icon.
Record Macro Dialog Box
The Record Macro dialog box lets you set the details of a macro and then start recording. You set
important details like the macro name, the key shortcut for running the macro, where the macro will
be stored, and a description of the macro in the Record Macro dialog box. The Record Macro
dialog box can be displayed from the Macros drop-down list on the VIEW tab.
Excel 2013: PivotTables and Macros | 37
Towson University Lesson 2: Automating Worksheet Functionality
Macros Icon
Record Macro Dialog
Box
Figure 2-3: The Record Macro dialog box.
Naming Macros
There are a few rules for naming macros.
The name must start with a letter.
The name cannot contain spaces.
The name can contain letters, numbers, and the underscore character (_).
The name should not conflict with any other object in the worksheet or workbook, or with any
built-in names.
If these naming rules are not followed, you will get an error message.
Figure 2-4: Naming macros in the Macro dialog box.
38 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Naming Macros
Macro Security and the XLSM File Format
Excel macros are a prevalent tool for transferring computer viruses. Excel 2013 requires that you
save any workbooks that use macros in the new macro-enabled workbook format (.xlsm) to provide
increased security. When you attempt to open an XLSM file, you are given a security warning so that
you can decide on the trustworthiness of the source of the file. If you don't save your workbook in
the XLSM format, any macros used in your file will not be saved.
Macro Storage
You can save macros in three different sites: the current workbook, a new workbook, or a Personal
Macro workbook. Saving in the current workbook requires that the workbook be open in order to
use it in other files. To save it in any other file, at any time, save as a Personal Macro workbook.
Note: Check out the LearnTO Use Relative Referencing When Recording a Macro
presentation from the LearnTO tile for this course on your LogicalCHOICE Course screen.
How to Create a Macro
Use this procedure to create a macro.
Record a Macro
To record a macro:
1. Open a worksheet where you need to record a macro.
2. Whenever necessary, change to relative referencing by selecting VIEWMacrosMacros
down-arrowUse Relative References.
3. Select VIEWMacrosMacros down-arrowRecord Macro.
4. In the Record Macro dialog box, in the Macro name text box, type a name. Note: If you want
the macro to automatically open whenever the file is opened, type Auto_Open in the Macro
name text box instead of giving the macro a unique name.
5. Using the Shortcut key text box, type a letter to add a shortcut key for the macro.
6. From the Store macro in drop-down list, select a location for the macro to be stored.
Select Personal Macro Workbook to save the macro in the Personal workbook that opens
when you open Excel. This is the best option when you are going to use this macro in other
workbooks.
Select New Workbook to save and use the macro in a new workbook.
Select This Workbook to save the macro in the current workbook.
7. In the Description text box, type a description of what the macro will do when run.
8. Select OK to record the macro.
9. Complete the steps of the macro.
10. Select VIEWMacrosMacros down-arrowStop Recording to stop recording the macro.
11. Select FILESave AsComputerBrowse, and then, in the Save As dialog box, from the
Save as type drop-down list, select the .xlsm extension to save the macro and the workbook.
Visual Basic for Applications
Visual Basic for Applications (VBA) is the programing language that Microsoft Office 2013 uses to
handle macros. As you record a macro, Excel translates your actions into VBA code.
Note: If you know how to program in VBA, you can directly write macros using VBA.
Excel 2013: PivotTables and Macros | 39
Towson University Lesson 2: Automating Worksheet Functionality
You may want to show
LearnTO Use Relative
Referencing When
Recording a Macro from
the LogicalCHOICE
Course screen, or have
students navigate out to
the Course screen and
watch it themselves as a
supplement to your
instruction. If not, please
remind students to visit
the LearnTOs for this
course on their
LogicalCHOICE Course
screen after class for
supplemental
information and
additional resources.
Visual Basic for
Applications
The Visual Basic Editor
The Visual Basic Editor is an Excel add-in that you can use to view and edit a macro in VBA.
Figure 2-5: Visual Basic for Applications.
The Visual Basic Editor interface is made up of four components.
Component Description
Project Explorer Displays a hierarchical list of all VBA modules in all open documents. The
normal template is called Normal. Active documents appear as Project objects.
Active templates appear as Template Project objects.
Properties
window
Displays the properties of the object selected in the Project Explorer window.
A property is a characteristic of the object. One property of a VBA module is
the module's name.
Code Shows the actual VBA code for the macro, which can be edited.
Immediate
window
Shows debugging information from the code or commands typed directly into
the window.
Macro Settings
The security level applied to a macro can be set in the Macro Settings category of the Trust
Center dialog box. There are five security settings.
40 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Option Description
Disable all macros without
notification
Disables all macros in a workbook without issuing a security alert.
Only macros saved in the document or from a trusted location
are allowed to run.
Disable all macros with
notification
Disables all macros, but it issues a security alert. This is the
default setting.
Disable all macros except
digitally signed macros
Disables all macros that are not digitally signed by a trusted
publisher.
Enable all macros Enables all macros. This is the lowest level of protection, which
could leave your computer open to malicious code.
Trust access to the VBA
project object model
Allows macros to access the core level of the Microsoft Visual
Basic project model. This option is a security risk for most users,
and it should only be used by developers.
How to Edit a Macro
Use the following procedures to edit a macro.
Adjust Security Settings
To adjust a macro's security settings:
1. Select FILEOptions.
2. In the Excel Options dialog box, select Trust Center, and then select Trust Center Settings.
3. In the Trust Center dialog box, select the level of security you require. Select OK to save this
macro security setting.
4. Close the Excel Options dialog box.
Edit a Macro
To edit a macro:
1. Open the worksheet that has the macro you need to edit.
2. If the security setting is set to disable the macro, you need to enable the macro.
In the SECURITY WARNING panel, select Enable Content.
3. Select VIEWMacrosMacros down-arrowView Macros.
4. In the Macro dialog box, in the Macro name list box, select the macro you need to edit. Then,
select Edit.
5. Make the needed changes in the macro in the code window, and then save your changes.
6. Return to Excel.
7. Test the macro you just edited.
8. Save the file.
Copy a Macro
To copy a macro to another workbook:
1. Open the workbooks you want macros copied from and to.
2. In either open workbook, select VIEWMacrosMacros down-arrowView Macros.
3. From the Macro dialog box, select the macro you would like to copy, and then select Edit.
4. From the Microsoft Visual Basic for Applications window, drag the macro you would like to
copy to the desired workbook.
a. In the Project - VBA Project pane, if necessary, expand the hierarchy for the workbook that
contains the macro.
Excel 2013: PivotTables and Macros | 41
Towson University Lesson 2: Automating Worksheet Functionality
b. In the Modules node, drag the desired macro to the destination workbook.
c. Expand the Modules node in the destination workbook's hierarchy, and then verify that the
macro copied to the workbook.
5. Close the Microsoft Visual Basic for Applications window.
6. Close the workbook that originally contained the macro.
7. Save the destination workbook in the .xlsm file format.
8. If desired, run the macro on the destination workbook.
9. Save and close the file.
42 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
ACTIVITY 2-3
Creating a Macro
Data Files
C:\091016Data\Automating Worksheet Functionality\My_Asian_Royalties.xlsx
Before You Begin
The Excel 2013 application is open.
Scenario
Your sales manager wants you to make all the worksheets from the Asian division look exactly the
same so that they can be more easily identified.
She wants you to make the following changes:
All the worksheets' titles to red, 24 point.
All the worksheets' fonts to Times New Roman.
All column headers to bold.
All columns of numerical data to the currency format.
Instead of manually making all these changes, you decide to format one worksheet and create a
macro that you will apply to the other two worksheets.
1. From the C:\091016Data\Automating Worksheet Functionality folder, open My_Asian_Royalties.xlsx.
2. Record the steps that you want to use as a macro.
a) Select VIEWMacrosMacros down-arrowRecord Macro.


3. Name the macro so that you can reference it for later use.
a) In the Record Macro dialog box, in the Macro name text box, type RoyaltyFormattingMacro
b) In the Shortcut key text box, type R
Note: Excel automatically adds the Shift key to the shortcut in the Record
Macro dialog box because you pressed it when typing the capital "R."
Excel 2013: PivotTables and Macros | 43
Towson University Lesson 2: Automating Worksheet Functionality
c) In the Store macro in drop-down list, verify that This Workbook is selected.
d) In the Description text box, type This macro sets the formatting for author royalty worksheets.


e) Select OK.
4. Change the font to Times New Roman.
a) Select all the text in the worksheet.
b) Select HOMEFontFont down-arrowTimes New Roman.
5. Change the workbook's title font to 24 point red.
a) Select cells A1 and A2. In the Font group, change the titles to 24 point and the color red.
6. Make the column headers bold.
a) Select cells B4:D4.
b) In the Font group, change the headers to bold by selecting the Bold button.
7. Format the cells so that all numerical data is set to currency.
a) Select the cells with numerical data C5:D17.

44 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training

b) In the Number group, from the drop-down list, select Currency.


8. Stop recording the macro.
a) Select VIEWMacrosMacros down-arrowStop Recording.
9. Save the file as a macro.
a) Select the FILESave As.
b) In the Save As section, select Computer.


c) In the right pane, under Computer, select the Automating Worksheet Functionality folder displaying
in the Current Folder section.
Note: This saves the file to the folder location from which you opened the
original file.
d) Save the file with the following information:
File name: My_Asian_Royalties
Save as type: Excel Macro-Enabled Workbook (*.xlsm)
10. Verify that the macro works.
a) Select the Old Sales worksheet and click anywhere on the sheet.
b) Press the shortcut key Ctrl+Shift+R.
c) Verify that the macro made the appropriate changes.
d) Run the macro on the New Sales worksheet.
11. Save the workbook.
Excel 2013: PivotTables and Macros | 45
Towson University Lesson 2: Automating Worksheet Functionality
ACTIVITY 2-4
Editing a Macro
Before You Begin
My_Asian_Royalties.xlsm is open.
Scenario
Your manager likes the macro, but she wants the title of the worksheets to be a little bit larger, so
she wants you to change it from 24 to 26 point font.
1. Select VIEWMacrosMacros down-arrowView Macros.
2. In the Macro dialog box, verify that RoyaltyFormattingMacro is present.


3. Edit the macro in Microsoft Visual Basic.
a) In the Macro dialog box, select the RoyaltyFormattingMacro in the list, and then select Edit.
b) In the Microsoft Visual Basic for Applications window, find the code for 24 point.
c) Delete 24 and type 26

46 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training

d) Close the Microsoft Visual Basic for Applications window.
4. Verify that the macro was edited.
a) In the open Excel worksheet, press the shortcut key Ctrl+Shift+R.
b) Verify that the text size has changed to 26 point in cells A1 and A2.
Note: You may need to select text in the cells, and then select the HOME tab
to verify that the font size has changed to 26 in the Font command group.
5. Save the workbook.
Excel 2013: PivotTables and Macros | 47
Towson University Lesson 2: Automating Worksheet Functionality
TOPIC C
Apply Conditional Formatting
Sometimes you need locate some specific data or make some parts of your worksheet stand out. In
this topic, you will apply conditional formatting.
Conditional formatting allows you to set criteria that, if met, will display that information in a
different format so that it is more distinctive. Conditional formatting lets you differentiate between
data more easily.
Conditional Formatting
Conditional formatting sets a specific format for cells or a range of cells based on criteria that you set.
Cells can contain numerical or textual data. There are default formats, but you can also set your own
formatting style.
Figure 2-6: Data with conditional formatting.
Conditional Formats
There are different conditional formats available from the Conditional Formatting command in
the Styles group on the HOME tab.
Format Purpose
Highlight Cells Rules Finds cells within a range. You format these cells based on a
comparison operator. You apply this format by selecting the
necessary option from the Highlight Cells submenu.
Top/Bottom Rules Finds the highest and lowest values in a range and allows you to
set cutoff values. You apply this format by selecting the necessary
option from the Top/Bottom Rules submenu.
Data Bars Shows the value of a cell relative to other cells. The value in the
cell sets the length of the data bar. You can set this format by
selecting the data bar format from the Data Bars gallery. It is
possible to customize a data bar.
48 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Conditional Formatting
Format Purpose
Color Scales Shows data distribution and variation. The shade of color used
represents higher, middle, or lower values. You set this format by
picking a color scheme from the Color Scales gallery. It is
possible to customize a color scale.
Icon Sets Allows you to annotate and classify data into three to five
categories using icon sets. Every category is represented by an
icon. You apply this format by selecting an icon set type from the
Icon Sets gallery. It is possible to customize icon sets.
The Conditional Formatting Rules Manager Dialog Box
The Conditional Formatting Rules Manager dialog box allows you to set the conditional
formatting rules for the appropriate data sets. You can use this dialog box to make all conditional
formatting changes, including creating, editing, and deleting. All rules used in a worksheet are
shown. The Conditional Formatting Rules Manager dialog box is accessed from the
Conditional Formatting drop-down list on the HOME tab.
Figure 2-7: The Conditional Formatting Rules Manager dialog box.
The New Formatting Rule Dialog Box
Six kinds of conditional formatting rules are available in the New Formatting Rule dialog box.
Rule Type Description
Format all cells based on their
values
Cells are formatted depending on their values. There is no
need to set maximum or minimum values. This option cannot
be used for text; it can only be used for numeric data.
Format only cells that contain Cell format is set by its numeric, text, or data type.
Format only top or bottom
ranked values
Selects the top or bottom percentage of cells in the range.
Format only values that are
above or below average
Cells are formatted if they are above or below the average.
Excel 2013: PivotTables and Macros | 49
Towson University Lesson 2: Automating Worksheet Functionality
Conditional Formatting
Rules Manager
Rule Type Description
Format only unique or duplicate
values
Conditional formatting only applies to unique or duplicate
values.
Use a formula to determine
which cells to format
A formula is set to determine which cells are conditionally
formatted.
Clear Rules
You can remove conditional formatting rules from the Clear Rules submenu in the Conditional
Formatting drop-down list. From this menu, you can delete conditional formatting rules from a
worksheet, selected cells, tables, or PivotTables.
Note: Check out the LearnTO Use Data Bars and Icon Sets presentation from the LearnTO
tile for this course on your LogicalCHOICE Course screen.
How to Apply Conditional Formatting
Use these procedures to apply conditional formatting.
Apply Conditional Formatting
To apply conditional formatting:
1. Select the cell or cell range to apply conditional formatting to.
2. Select HOMEStylesConditional Formatting.
3. Select the desired type of conditional formatting.
Select Data Bars, Color Scales, or Icon Sets, and then select the desired option from the
subsequent gallery.
Select Highlight Cells Rules or Top/Bottom Rules, select the desired criteria type, and
then, in the subsequent dialog box, enter the specific criteria and select the desired formatting
option, and select OK.
Edit an Existing Conditional Formatting Rule
To edit an existing conditional formatting rule:
1. Select HOMEStylesConditional FormattingManage Rules.
2. In the Conditional Formatting Rules Manager dialog box, from the Show formatting rules
for drop-down menu, select the location for which you wish to view applied conditional
formatting.
3. From the list of rules, select the rule you need to edit.
4. Select Edit Rule.
5. In the Edit Formatting Rule dialog box, edit the rule, and then select OK.
6. In the Conditional Formatting Rules Manager dialog box, select OK to apply the rule.
50 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
You may want to show
LearnTO Use Data Bars
and Icon Sets from the
LogicalCHOICE Course
screen, or have students
navigate out to the
Course screen and
watch it themselves as a
supplement to your
instruction. If not, please
remind students to visit
the LearnTOs for this
course on their
LogicalCHOICE Course
screen after class for
supplemental
information and
additional resources.
ACTIVITY 2-5
Applying Conditional Formatting
Before You Begin
My_Asian_Royalties.xlsm is open.
Scenario
The Asian sales manager would like to know if there is an easy way to highlight all authors who earn
more than $25,000 because there maybe additional tax requirements for authors who earn this
much. You will set conditional formatting to apply to all authors who make this amount.
1. Set conditional formatting so that authors who earn more than $25,000 are highlighted.
a) Select the Author Sales worksheet.
b) Select cells D5 to D15.
c) Select HOMEStylesConditional Formatting.
d) From the Conditional Formatting drop-down list, select Highlight Cells Rules, and then select
Greater Than.
e) In the Format cells that are GREATER THAN field, type 25000
f) Select OK.
2. Verify that the authors who have earned more than $25,000 now have their royalties highlighted with
dark red text on a light red cell background.


3. Save the workbook.
Excel 2013: PivotTables and Macros | 51
Towson University Lesson 2: Automating Worksheet Functionality
ACTIVITY 2-6
Editing a Conditional Formatting Rule
Before You Begin
My_Asian_Royalties.xlsm is open.
Scenario
The manager likes the new formatting, which makes it very easy for his people to see exactly who is
making more than the threshold of $25,000. However, he apologizes because he gave you the wrong
information. Actually, authors who make more than $35,000 may face additional tax liability. He
would also like you change the formatting because he thinks the color scheme might be confusing.
1. Edit the conditional formatting rule.
a) Select HOMEStylesConditional FormattingManage Rules.
b) In the Conditional Formatting Rules Manager dialog box, in the Show formatting rules for drop-down
list, select This Worksheet.
c) Select Edit Rule.
d) In the Edit Formatting Rule dialog box, in the Select a Rule Type list, ensure Format only cells that
contain is selected.
e) In the Format only cells with section, change 25000 to 35000


f) In the Preview section, select Format.
g) Change the color from dark red to blue.

52 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training

2. Select OK three times.
3. Verify that the conditional formatting now applies only to values above $35,000, and that the text is now
blue.


4. Save the workbook.
Excel 2013: PivotTables and Macros | 53
Towson University Lesson 2: Automating Worksheet Functionality
TOPIC D
Add Data Validation Criteria
Restricting the type of data that can be input into your workbook gives you greater control over the
information you need to work with. Some cells really need a numeral, others should have times,
dates, or whole numbers. In this topic, you will add data validation criteria.
Setting data validation rules before you enter data guarantees that all input values will fall within a
range that you set.
Data Validation
Data validation restricts the input type of a value based on a specific set of criteria. When you apply
data validation to a cell or a range of cells, the cells can only accept the specified type of data. Trying
to enter data that does not meet the criteria set for the cells will generate an error message. You can
set a specific input message to inform users why the data they attempted to enter is unacceptable.
Figure 2-8: The Data Validation icon.
The Data Validation Dialog Box
The Data Validation dialog box gives you three tabs to set the criteria settings, input message, and
error alert.
54 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Data Validation
The Data Validation
Dialog Box
Figure 2-9: The Data Validation dialog box.
Tab Function
Settings Sets the permitted the value type, such as decimal, date, and time. The possible
range can be set here. You can also create a drop-down list that only allows
particular entries here.
Input Message Sets the specific title for and the description of the data allowed in the cell.
Error Alert Allows you to set the style, title, and description of an error that displays when
the input data is not within the specified criteria.
How to Add Data Validation Criteria
Follow these procedures to add data validation criteria.
Add a Data Validation Rule
To add a data validation rule:
1. In an Excel worksheet, choose the data range that you need to apply data validation to.
2. Select DATAData ToolsData ValidationData Validation.
3. In the Data Validation dialog box, on the Settings tab, from the Allow drop-down list, specify
the criteria type.
Select Any value to accept any value, either a number or text.
Select Whole number to require input to be only whole numbers.
Select Decimal to require input to allow decimals.
Select List to restrict the input to a specified list of entry options.
Select Date to restrict the input to allow only dates.
Select Time to restrict the input to allow only times.
Select Text length to restrict the length of the text input.
Select Custom to specify custom criteria.
4. From the Data drop-down list, select a comparison operator.
Excel 2013: PivotTables and Macros | 55
Towson University Lesson 2: Automating Worksheet Functionality
5. In the text boxes below the Data drop-down list, set any needed values for a range. Note:
Different text boxes display depending on the comparison operator you select in the Data drop-
down list.
6. On the Input Message tab, create a custom message.
a. In the Title text box, type a title.
b. In the Input Message text area, if desired, type an optional message.
7. To create an error message, make changes to the default settings on the Error Alert tab.
a. From the Style drop-down list, select an error icon.
b. In the Title text box, enter a title.
c. In the Error message text box, type the error message.
8. Select OK to apply the data validation criteria.
9. Test your rules by trying to input invalid data into the range you just applied validation to. Note:
Text and data already entered in the cells that does not meet the data validation criteria will not
be affected. If you try to change the entries after the data validation has been applied, it must
meet the set criteria.
Create a Drop-Down List for a Range of Cells
To create a drop-down list for a range cells:
1. Create a list of valid entries for the drop-down list. Each item must be in a separate cell in a
contiguous range of cells, either in a row or in a column.
2. Select the cell or the range of cells where the drop-down list will appear.
3. Select DATAData ToolsData ValidationData Validation.
4. In the Data Validation dialog box, select the Settings tab.
5. From the Allow drop-down list, select List.
6. In the Source text box, type an equal sign and enter the cell or the range that contains the valid
entries. Or, select the Collapse Dialog button, navigate to and select the cell or range that
contains the valid entries, and then press Enter.
7. Verify that the In-cell dropdown check box is checked so that a drop-down arrow will display
in the cell.
8. If desired, on the Input Message tab, create a message.
9. If desired, on the Error Alert tab, create a message for invalid entries.
10. Select OK.
56 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
ACTIVITY 2-7
Adding Data Validation Criteria
Before You Begin
My_Asian_Royalties.xlsm is open and the Author Sales worksheet is selected.
Scenario
The manager of the Asian sales division would like to add a place in the royalties workbook where
her staff can add and track their sales. There have been some problems in the past with data being
entered in the wrong place, which required a long and miserable effort to correct. You will need to
apply data validation criteria to avoid this issue in the future.
1. Set the Sales column so that only whole numbers can be input.
a) If necessary, navigate to the Author Sales worksheet.
b) Select cells C5:C15.
c) Select DATAData ToolsData ValidationData Validation.
d) In the Data Validation dialog box, on the Settings tab, from the Allow drop-down list, select Whole
number.
e) In the Data drop-down list, verify that between is selected.
f) In the Minimum text box, type 0
g) In the Maximum text box, type 1000000
2. Set an error message for the Sales column so that your message displays when someone tries to enter
data that is not a whole number.
a) Select the Error Alert tab.
b) In the Style drop-down list, select Warning.
c) In the Title text box, type Sales Column Data Error
d) In the Error message text box, type This column requires a whole number.
e) Select OK.

Excel 2013: PivotTables and Macros | 57
Towson University Lesson 2: Automating Worksheet Functionality

3. Set the Royalty column to accept only numerical input.
a) Select D5:D15.
b) From the Data Validation drop-down list, select Data Validation.
c) In the Data Validation dialog box, select the Settings tab.
d) From the Allow drop-down window, select Decimal.
e) In the Data drop-down list, verify that between is selected.
f) In the Minimum text box, type 0
g) In the Maximum text box, type 1000000
h) Select OK.
4. Verify your validation criteria are saved correctly.
a) Select cell C8.
b) Enter 112.5 and then press Tab.
c) In the Sales Column Data Error dialog box, select Cancel.
d) Select cell D11.
e) Enter Roger Clifton and then press Tab.
f) In the Microsoft Excel dialog box, select Cancel.
5. Save and close the file.
58 | Excel 2013: PivotTables and Macros
Lesson 2: Automating Worksheet Functionality OTS Training
Summary
In this lesson, you automated worksheet functionality. You created and edited macros to complete
commonly occurring tasks. You applied conditional formatting to give yourself additional flexibility
over the data in your worksheet. Finally, you set data validation criteria that restricted the type of
data that could be entered in a cell or range of cells.
Which of these automation tools do you think will be most important or useful to you? Why?
A: Answers will vary, but different people in different businesses may value any of these time-saving
options. For most people, macros can be the most useful because they enable someone to quickly
establish a style that can easily be applied to many other worksheets. For some people, conditional
formatting will be very helpful in making workbooks more efficient.
How does using workbooks make business easier? Will these automation tools make the process of
building and maintaining workbooks easier for you?
A: Answers will vary, but may include that many complicated calculations that businesses require had to
be done by hand or with a calculator in the past. Having this work done automatically improves the
accuracy of information and lets a business run more sophisticated formulas and data analysis than
would otherwise be possible.
Note: Check your LogicalCHOICE Course screen for opportunities to interact with your
classmates, peers, and the larger LogicalCHOICE online community about the topics covered in
this course or other topics you are interested in. From the Course screen, you can also access
available resources for a more continuous learning experience.
Excel 2013: PivotTables and Macros | 59
Towson University Lesson 2: Automating Worksheet Functionality
Encourage students to
use the social
networking tools
provided on the
LogicalCHOICE Home
screen to follow up with
their peers after the
course is completed for
further discussion and
resources to support
continued learning.
Lesson Labs
Lesson labs are provided as an additional learning resource for this course. The labs may or
may not be performed as part of the classroom activities. Your instructor will consider setup
issues, classroom timing issues, and instructional needs to determine which labs are
appropriate for you to perform, and at what point during the class. If you do not perform
the labs in class, your instructor can tell you if you can perform them independently as self-
study, and if there are any special setup requirements.
Lesson Lab 2-1
Automating Worksheet Functionality
Activity Time: 10 minutes
Data Files
C:\091016Data\Automating Worksheet Functionality\Promotions_Budget.xlsx
Scenario
The promotions workbook has two worksheets. Your manager wants them to look
exactly the same so that the department's documents are consistent. She would like you
to:
Highlight any total higher than $3,000 by applying a yellow fill with dark yellow
text.
Cap the maximum value at $5,000 using data validation.
Increase the font size for the monthly total to 16 point.
It will be easier to make all the changes to one worksheet and record the process so
that you can apply it to any other worksheets.
1. Open the Promotions_Budget.xlsx workbook, and select either worksheet.
2. Record a macro of the changes.
3. Select cells C5:C10. Use conditional formatting to highlight any value greater than $3000.
4. Set data validation criteria so that the maximum value for column C is $5000.
5. Select cells B13 and C13 and change the font size to 16 point.
6. Stop recording and save the macro.
7. Run the macro on the other worksheet, and then save and close the file.
62 | Excel 2013: PivotTables and Macros
Lesson Labs OTS Training

Das könnte Ihnen auch gefallen