- •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
CHAPTER
Visualizing Data
Using Conditional
Formatting
This chapter explores conditional formatting, one of Excel’s most versatile features. You can apply conditional formatting to a cell so that the cell looks different, depending on its contents.
Microsoft made significant enhancements to conditional formatting in Excel 2007, and it’s now a useful tool for visualizing numeric data. You’ll find a few more conditional formatting improvements in Excel 2010.
About Conditional Formatting
Conditional formatting enables you to apply cell formatting selectively and automatically, based on the contents of the cells. For example, you can set things up so that all negative values in a range have a light-yellow background color. When you enter or change a value in the range, Excel examines the value and checks the conditional formatting rules for the cell. If the value is negative, the background is shaded. If not, no formatting is applied.
Conditional formatting is a useful way to quickly identify erroneous cell entries or cells of a particular type. You can use a format (such as bright-red cell shading) to make particular cells easy to identify.
Figure 20.1 shows a worksheet with nine ranges, each with a different type of conditional formatting rule applied. Here’s a brief explanation of each:
•Greater than 10: Values greater than 10 are highlighted with a different background color. This rule is just one of many numeric value related rules that you can apply.
•Above average: Values that are higher than the average value are highlighted.
IN THIS CHAPTER
An overview of Excel’s conditional formatting feature
How to use the graphical conditional formats
Examples of using conditional formatting formulas
Tips for using conditional formatting
481
Part III: Creating Charts and Graphics
•Duplicate values: Values that appear more than one time are highlighted.
•Words that contain X: If the cell contains X (upperor lowercase), the cell is highlighted.
•Data bars: Each cell displays a horizontal bar, proportional to its value.
•Color Scale: The background color varies, depending on the value of the cells. You can choose from several different color scales or create your own.
•Icon Set: One of several icon sets. It displays a small graphic in the cell. The graphic varies, depending on the cell value.
•Icon Set: Another icon set, with all but one icon hidden.
•Custom rule: The rule for this checkerboard pattern is based on a formula:
=MOD(ROW(),2)=MOD(COLUMN(),2)
On the CD
This workbook, named conditional formatting examples.xlsx, is available on the companion CD-ROM. n
FIGURE 20.1
This worksheet demonstrates a few conditional formatting rules.
482
Chapter 20: Visualizing Data Using Conditional Formatting
Specifying Conditional Formatting
To apply a conditional formatting rule to a cell or range, select the cells and then use one of the commands from the Home Styles Conditional Formatting drop-down list to specify a rule. The choices are
•Highlight Cell Rules: Examples rules include highlighting cells that are greater than a particular value, between two values, contain specific text string, a date, or are duplicated.
•Top Bottom Rules: Examples include highlighting the top 10 items, the items in the bottom 20 percent, and items that are above average.
•Data Bars: Applies graphic bars directly in the cells, proportional to the cell’s value.
•Color Scales: Applies background color, proportional to the cell’s value.
•Icon Sets: Displays icons directly in the cells. The icons depend on the cell’s value.
•New Rule: Enables you to specify other conditional formatting rules, including rules based on a logical formula.
•Clear Rules: Deletes all the conditional formatting rules from the selected cells.
•Manage Rules: Displays the Conditional Formatting Rules Manager dialog box, in which you create new conditional formatting rules, edit rules, or delete rules.
Formatting types you can apply
When you select a conditional formatting rule, Excel displays a dialog box specific to that rule. These dialog boxes have one thing in a common: a drop-down list with common formatting suggestions.
Figure 20.2 shows the dialog box that appears when you choose Home Styles Conditional Formatting Highlight Cells Rules Between. This particular rule applies the formatting if the value in the cell falls between two specified values. In this case, you enter the two values (or specify cell references), and then use choices from the drop-down list to set the type of formatting to display if the condition is met.
FIGURE 20.2
One of several different conditional formatting dialog boxes.
483
Part III: Creating Charts and Graphics
Excel 2010 Improvements
If you’ve used conditional formatting in Excel 2007, you’ll find several improvements in Excel 2010:
•Data bars display proportionally.
•Data bars can display in a solid color with a border. Previously, data bars always displayed with a gradient.
•Data bars handle negative values much better.
•You can specify minimum and maximum values for data bars.
•You can create customized Icon sets.
•Hiding one or more icons in an icon set is easy.
The formatting suggestions in the drop-down list are just a few of thousands of different formatting combinations. If none of Excel’s suggestions are what you want, choose the Custom Format option to display the Format Cells dialog box. You can specify the format in any or all of the four tabs:
Number, Font, Border, and Fill.
Note
The Format Cells dialog box used for conditional formatting is a modified version of the standard Format Cells dialog box. It doesn’t have the Alignment and Protection tabs, and some of the Font formatting options are disabled. The dialog box also includes a Clear button that clears any formatting already selected. n
Making your own rules
For do-it-yourself types, Excel provides the New Formatting Rule dialog box, shown in Figure 20.3. Access this dialog box by choosing Home Styles Conditional Formatting New Rules.
Use the New Formatting Rule dialog box to re-create all the conditional format rules available via the Ribbon, as well as new rules. First, select a general rule type from the list at the top of the dialog box. The bottom part of the dialog box varies, depending on your selection at the top. After you specify the rule, click the Format button to specify the type of formatting to apply if the condition is met. An exception is the first rule type, which doesn’t have a Format button (it uses graphics rather than cell formatting).
Here is a summary of the rule types:
•Format all cells based on their values: Use this rule type to create rules that display data bars, color scales, or icon sets.
•Format only cells that contain: Use this rule type to create rules that format cells based on mathematical comparisons (greater than, less than, greater than or equal to, less than or equal to, equal to, not equal to, between, not between). You can also create rules based
484