- •About the Author
- •About the Technical Editor
- •Credits
- •Is This Book for You?
- •Software Versions
- •Conventions This Book Uses
- •What the Icons Mean
- •How This Book Is Organized
- •How to Use This Book
- •What’s on the Companion CD
- •What Is Excel Good For?
- •What’s New in Excel 2010?
- •Moving around a Worksheet
- •Introducing the Ribbon
- •Using Shortcut Menus
- •Customizing Your Quick Access Toolbar
- •Working with Dialog Boxes
- •Using the Task Pane
- •Creating Your First Excel Worksheet
- •Entering Text and Values into Your Worksheets
- •Entering Dates and Times into Your Worksheets
- •Modifying Cell Contents
- •Applying Number Formatting
- •Controlling the Worksheet View
- •Working with Rows and Columns
- •Understanding Cells and Ranges
- •Copying or Moving Ranges
- •Using Names to Work with Ranges
- •Adding Comments to Cells
- •What Is a Table?
- •Creating a Table
- •Changing the Look of a Table
- •Working with Tables
- •Getting to Know the Formatting Tools
- •Changing Text Alignment
- •Using Colors and Shading
- •Adding Borders and Lines
- •Adding a Background Image to a Worksheet
- •Using Named Styles for Easier Formatting
- •Understanding Document Themes
- •Creating a New Workbook
- •Opening an Existing Workbook
- •Saving a Workbook
- •Using AutoRecover
- •Specifying a Password
- •Organizing Your Files
- •Other Workbook Info Options
- •Closing Workbooks
- •Safeguarding Your Work
- •Excel File Compatibility
- •Exploring Excel Templates
- •Understanding Custom Excel Templates
- •Printing with One Click
- •Changing Your Page View
- •Adjusting Common Page Setup Settings
- •Adding a Header or Footer to Your Reports
- •Copying Page Setup Settings across Sheets
- •Preventing Certain Cells from Being Printed
- •Preventing Objects from Being Printed
- •Creating Custom Views of Your Worksheet
- •Understanding Formula Basics
- •Entering Formulas into Your Worksheets
- •Editing Formulas
- •Using Cell References in Formulas
- •Using Formulas in Tables
- •Correcting Common Formula Errors
- •Using Advanced Naming Techniques
- •Tips for Working with Formulas
- •A Few Words about Text
- •Text Functions
- •Advanced Text Formulas
- •Date-Related Worksheet Functions
- •Time-Related Functions
- •Basic Counting Formulas
- •Advanced Counting Formulas
- •Summing Formulas
- •Conditional Sums Using a Single Criterion
- •Conditional Sums Using Multiple Criteria
- •Introducing Lookup Formulas
- •Functions Relevant to Lookups
- •Basic Lookup Formulas
- •Specialized Lookup Formulas
- •The Time Value of Money
- •Loan Calculations
- •Investment Calculations
- •Depreciation Calculations
- •Understanding Array Formulas
- •Understanding the Dimensions of an Array
- •Naming Array Constants
- •Working with Array Formulas
- •Using Multicell Array Formulas
- •Using Single-Cell Array Formulas
- •Working with Multicell Array Formulas
- •What Is a Chart?
- •Understanding How Excel Handles Charts
- •Creating a Chart
- •Working with Charts
- •Understanding Chart Types
- •Learning More
- •Selecting Chart Elements
- •User Interface Choices for Modifying Chart Elements
- •Modifying the Chart Area
- •Modifying the Plot Area
- •Working with Chart Titles
- •Working with a Legend
- •Working with Gridlines
- •Modifying the Axes
- •Working with Data Series
- •Creating Chart Templates
- •Learning Some Chart-Making Tricks
- •About Conditional Formatting
- •Specifying Conditional Formatting
- •Conditional Formats That Use Graphics
- •Creating Formula-Based Rules
- •Working with Conditional Formats
- •Sparkline Types
- •Creating Sparklines
- •Customizing Sparklines
- •Specifying a Date Axis
- •Auto-Updating Sparklines
- •Displaying a Sparkline for a Dynamic Range
- •Using Shapes
- •Using SmartArt
- •Using WordArt
- •Working with Other Graphic Types
- •Using the Equation Editor
- •Customizing the Ribbon
- •About Number Formatting
- •Creating a Custom Number Format
- •Custom Number Format Examples
- •About Data Validation
- •Specifying Validation Criteria
- •Types of Validation Criteria You Can Apply
- •Creating a Drop-Down List
- •Using Formulas for Data Validation Rules
- •Understanding Cell References
- •Data Validation Formula Examples
- •Introducing Worksheet Outlines
- •Creating an Outline
- •Working with Outlines
- •Linking Workbooks
- •Creating External Reference Formulas
- •Working with External Reference Formulas
- •Consolidating Worksheets
- •Understanding the Different Web Formats
- •Opening an HTML File
- •Working with Hyperlinks
- •Using Web Queries
- •Other Internet-Related Features
- •Copying and Pasting
- •Copying from Excel to Word
- •Embedding Objects in a Worksheet
- •Using Excel on a Network
- •Understanding File Reservations
- •Sharing Workbooks
- •Tracking Workbook Changes
- •Types of Protection
- •Protecting a Worksheet
- •Protecting a Workbook
- •VB Project Protection
- •Related Topics
- •Using Excel Auditing Tools
- •Searching and Replacing
- •Spell Checking Your Worksheets
- •Using AutoCorrect
- •Understanding External Database Files
- •Importing Access Tables
- •Retrieving Data with Query: An Example
- •Working with Data Returned by Query
- •Using Query without the Wizard
- •Learning More about Query
- •About Pivot Tables
- •Creating a Pivot Table
- •More Pivot Table Examples
- •Learning More
- •Working with Non-Numeric Data
- •Grouping Pivot Table Items
- •Creating a Frequency Distribution
- •Filtering Pivot Tables with Slicers
- •Referencing Cells within a Pivot Table
- •Creating Pivot Charts
- •Another Pivot Table Example
- •Producing a Report with a Pivot Table
- •A What-If Example
- •Types of What-If Analyses
- •Manual What-If Analysis
- •Creating Data Tables
- •Using Scenario Manager
- •What-If Analysis, in Reverse
- •Single-Cell Goal Seeking
- •Introducing Solver
- •Solver Examples
- •Installing the Analysis ToolPak Add-in
- •Using the Analysis Tools
- •Introducing the Analysis ToolPak Tools
- •Introducing VBA Macros
- •Displaying the Developer Tab
- •About Macro Security
- •Saving Workbooks That Contain Macros
- •Two Types of VBA Macros
- •Creating VBA Macros
- •Learning More
- •Overview of VBA Functions
- •An Introductory Example
- •About Function Procedures
- •Executing Function Procedures
- •Function Procedure Arguments
- •Debugging Custom Functions
- •Inserting Custom Functions
- •Learning More
- •Why Create UserForms?
- •UserForm Alternatives
- •Creating UserForms: An Overview
- •A UserForm Example
- •Another UserForm Example
- •More on Creating UserForms
- •Learning More
- •Why Use Controls on a Worksheet?
- •Using Controls
- •Reviewing the Available ActiveX Controls
- •Understanding Events
- •Entering Event-Handler VBA Code
- •Using Workbook-Level Events
- •Working with Worksheet Events
- •Using Non-Object Events
- •Working with Ranges
- •Working with Workbooks
- •Working with Charts
- •VBA Speed Tips
- •What Is an Add-In?
- •Working with Add-Ins
- •Why Create Add-Ins?
- •Creating Add-Ins
- •An Add-In Example
- •System Requirements
- •Using the CD
- •What’s on the CD
- •Troubleshooting
- •The Excel Help System
- •Microsoft Technical Support
- •Internet Newsgroups
- •Internet Web sites
- •End-User License Agreement
Part III: Creating Charts and Graphics
Sparkline Types
Excel 2010 supports three types of Sparklines. Figure 21.1 shows examples of the three types of Sparkline graphics, displayed in column H. Each Sparkline depicts the six data points to the left.
•Line: Similar to a line chart. As an option, the line can display with a marker for each data point. The first group in Figure 21.1 shows line Sparklines, with markers. A quick glance reveals that with the exception of Fund Number W-91, the funds have been losing value over the six-month period.
•Column: Similar to a column chart. The second group in Figure 21.1 shows the same data displayed with column Sparklines.
•Win/Loss: A “binary” type chart that displays each data point as a high block or a low block. The third group shows win/loss Sparklines. Notice that the data is different. Each cell displays the change from the previous month. In the Sparkline, each data point is depicted as a high block (win) or a low block (loss). In this example, a positive change from the previous month is a win, and a negative change from the previous month is a loss.
FIGURE 21.1
Three groups of Sparklines.
504
Chapter 21: Creating Sparkline Graphics
Why Sparklines?
If the term Sparkline seems odd, don’t blame Microsoft. Edward Tufte coined the term sparkline, and in his book, Beautiful Evidence (Graphics Press, 2006), he described it as
Sparklines: Intense, simple, word-sized graphics
In the case of Excel, Sparklines are cell-sized graphics. As you see in this chapter, Sparklines aren’t limited to lines.
Creating Sparklines
Figure 21.2 shows some data to be summarized with Sparklines. To create Sparkline graphics, follow these steps:
1.Select the data that will be depicted. If you are creating multiple Sparklines, select all the data. In this example, start by selecting B4:M12.
FIGURE 21.2
Data to be summarized with Sparklines.
2.With the data selected, choose Insert Sparklines, and click one of the three Sparkline types: Line, Column, or Win/Loss. Excel displays the Create Sparklines dialog box, as shown in Figure 21.3.
3.Specify the location for the Sparklines. Typically, you’ll put the Sparklines next to the data, but that’s not a requirement. Most of the time, you’ll use an empty range to hold the Sparklines. However, Excel does not prevent your from inserting Sparklines into cells that already contain data. The Sparkline location that you specify must match the source data in terms of number of rows or number of columns. For this example, specify N4:N12 as the Location Range.
4.Click OK. Excel creates the Sparklines graphics of the type you specified.
505
Part III: Creating Charts and Graphics
The Sparklines are linked to the data, so if you change any of the values in the data range, the Sparkline graphic will update.
FIGURE 21.3
Use the Create Sparklines dialog box to specify the data range and the location for the Sparkline graphics.
Tip
Most of the time, you’ll create Sparklines on the same sheet that contains the data. If you want to create Sparklines on a different sheet, start by activating the sheet where the Sparklines will be displayed. Then, in the Create Sparklines dialog box, specify the source data either by pointing or by typing the complete sheet reference (for example, Sheet1A1:C12). The Create Sparklines dialog box lets you specify a different sheet for the Data Range, but not for the Location Range. n
Understanding Sparkline Groups
Most of the time, you’ll probably create a group of Sparklines — one for each row or column of data. A worksheet can hold any number of Sparkline groups. Excel remembers each group, and you can work with the group as a single unit. For example, you can select one Sparkline in a group, and then modify the formatting of all Sparklines in the group. When you select one Sparkline cell, Excel displays an outline of all the other Sparklines in the group.
You can, however, perform some operations on an individual Sparkline in a group:
•Change the Sparkline’s data source. Select the Sparkline cell and choose Sparkline Tools Design Sparkline Edit Data Edit Single Sparkline’s Data. Excel displays a dialog box that lets you change the data source for the selected Sparkline.
•Delete the Sparkline. Select the Sparkline cell and choose Sparkline Tools Design Group Clear Clear Selected Sparklines.
Both operations are available from the shortcut menu that appears when you right-click a Sparkline cell.
You can also ungroup a set of Sparklines by selecting any Sparkline in the group and choosing Sparkline Tools Design Group Ungroup. After you ungroup a set of Sparklines, you can work with each Sparkline individually.
506
Chapter 21: Creating Sparkline Graphics
Figure 21.4 shows column Sparklines for the precipitation data.
FIGURE 21.4
Column Sparklines summarize the precipitation data for nine cities.
Customizing Sparklines
When you activate a cell that contains a Sparkline, Excel displays an outline around all the Sparklines in its group. You can then use the commands on the Sparkline Tools Design tab to customize the group of Sparklines.
Sizing Sparkline cells
When you change the width or height of a cell that contains a Sparkline, the Sparkline adjusts accordingly. In addition, you can insert a Sparkline into merged cells.
Figure 21.5 shows the same Sparkline, displayed at four sizes resulting from column width, row height, and merged cells.
FIGURE 21.5
A Sparkline at various sizes.
507
Part III: Creating Charts and Graphics
Handling hidden or missing data
By default, if you hide rows or columns that are used in a Sparkline graphic, the hidden data does not appear in the Sparkline. Also, missing data is displayed as a gap in the graphic.
To change these settings, choose Sparkline Tools Design Sparkline Edit Data Hidden and Empty Cells. In the Hidden and Empty Cell Settings dialog box that appears (see Figure 21.6), specify how to handle hidden data and empty cells.
FIGURE 21.6
The Hidden and Empty Cell Settings dialog box.
Changing the Sparkline type
As I mentioned earlier, Excel supports three Sparkline types: Line, Column, and Win/Loss. After you create a Sparkline or group of Sparklines, you can easily change the type by selecting the Sparkline and clicking one of the three icons in the Sparkline Tools Design Type group. If the selected Sparkline is part of a group, all Sparklines in the group are changed to the new type.
Tip
If you’ve customized the appearance, Excel remembers your customization settings for each type if you switch among Sparkline types. n
Changing Sparkline colors and line width
After you’ve created a Sparkline, changing the color is easy. Use the controls in the Sparkline Tools Design Style group.
Note
Colors used in Sparkline graphics are tied to the document theme. Thus, if you change the theme (by choosing Page Layout Themes Themes), the Sparkline colors will change to the new theme colors. See Chapter 6 for more information about document themes. n
For Line Sparklines, you can also specify the line width. Choose Sparkline Tools Design Style Sparkline Color Weight.
508
Chapter 21: Creating Sparkline Graphics
Highlighting certain data points
Use the commands in the Sparkline Tools Design Show group to customize the Sparklines to highlight certain aspects of the data. The options are
•High Point: Apply a different color to the highest data point in the Sparkline.
•Low Point: Apply a different color to the lowest data point in the Sparkline.
•Negative Points: Apply a different color to negative values in the Sparkline.
•First Point: Apply a different color to the first data point in the Sparkline.
•Last Point: Apply a different color to the last data point in the Sparkline.
•Markers: Show data markers in the Sparkline. This option is available only for Line Sparklines.
You control the color of the highlighting by using the Marker Color control in the Sparkline Tools Design Style group. Unfortunately, you cannot change the size of the markers in Line Sparklines.
Figure 21.7 shows some Line Sparklines with various types of highlighting applied.
FIGURE 21.7
Highlighting options for Line Sparklines.
Adjusting Sparkline axis scaling
When you create one or more Sparklines, they all use (by default) automatic axis scaling. In other words, the minimum and maximum vertical axis values are determined automatically for each Sparkline in the group, based on the numeric range of the data used by the Sparkline.
The Sparkline Tools Design Group Axis command lets you override this automatic behavior and control the minimum and maximum value for each Sparkline, or for a group of Sparklines. For even more control, you can use the Custom Value option and specify the minimum and maximum for the Sparkline group.
509
Part III: Creating Charts and Graphics
Figure 21.8 shows two groups of Sparklines. The group at the top uses the default axis settings (Automatic for Each Sparkline). Each Sparkline shows the six-month trend for the product, but there is no indication of the magnitude of the values.
FIGURE 21.8
The bottom group of Sparklines shows the effect of using the same axis minimum and maximum values for all Sparklines in a group.
For the Sparkline group at the bottom (which uses the same data), I changed the vertical axis minimum and maximum to use the Same for All Sparklines setting. With these settings in effect, the magnitude of the values across the products is apparent — but the trend across the months within a product is not apparent.
The axis scaling option you choose depends upon what aspect of the data you want to emphasize.
Faking a reference line
One useful feature that’s missing in the Excel 2010 implementation of Sparklines is a reference line. For example, it might be useful to show performance relative to a goal. If the goal is displayed as a reference line in a Sparkline, the viewer can quickly see whether the performance for a period exceeded the goal.
You can, however, to transform the data and then use a Sparkline axis as a fake reference line. Figure 21.9 shows an example. Students have a monthly reading goal of 500 pages. The range of data shows the actual pages read, with Sparklines in column H. The Sparklines show the sixmonth page data, but it’s impossible to tell who exceeded the goal, and when they did it.
Figure 21.10 shows another approach: Transforming the data such that meeting the goal is expressed as a 1, and failing to meet the goal is expressed as a –1. I used the following formula (in cell B18) to transform the original data:
=IF(B6>$C$2,1,-1)
510
Chapter 21: Creating Sparkline Graphics
FIGURE 21.9
Sparklines display the number of pages read per month.
FIGURE 21.10
Using Win/Loss Sparklines to display goal achievement.
I copied this formula to the other cells in B18:G25 range.
Using the transformed data, I created Win/Loss Sparklines to visualize the results. This approach is better than the original, but it doesn’t convey any magnitude differences. For example, you cannot tell whether the student missed the goal by 1 page or by 500 pages.
Figure 21.11 shows a better approach. Here, I transformed the original data by subtracting the goal from the pages read. The formula in cell B31 is
=B6-$C$2
I copied this formula to the other cells in the B31:G38 range, and created a group of Line Sparklines, with the axis turned on. I also enabled the Negative Points option so that negative values (failure to meet the goal) clearly stand out.
511