- •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
Worksheet
Formatting
Formatting your worksheet is like the icing on a cake — it may not be absolutely necessary, but it can make the end product a lot more attractive. In an Excel worksheet, formatting can also make it easier
for others to understand the worksheet’s purpose.
Stylistic formatting isn’t essential for every workbook that you develop — especially if it is for your own use only. On the other hand, it takes only a few moments to apply some simple formatting; and, after you apply it, the formatting will remain in place without further effort on your part.
In Chapter 5, I show how easy it is to apply formatting to a table. The information in this chapter applies to normal ranges. I show you how to work with the Excel formatting tools: fonts; colors; and styles, such as bold and italic. I also cover custom styles that you can create to make formatting large amounts of material in a similar way easier.
Getting to Know the
Formatting Tools
Figure 6.1 shows how even simple formatting can significantly improve a worksheet’s readability. The unformatted worksheet (on the left) is perfectly functional but not very readable compared with the formatted worksheet (on the right).
On the CD
This workbook is available on the companion CD-ROM. The file is named loan payments.xlsx.
IN THIS CHAPTER
Understanding how formatting can improve your worksheets
Getting to know the formatting tools
Using formatting in your worksheets
Using named styles for easier formatting
Understanding document themes
115
Part I: Getting Started with Excel
FIGURE 6.1
In just a few minutes, some simple formatting can greatly improve the appearance of your worksheets.
The Excel formatting tools are available in three locations:
•On the Home tab of the Ribbon
•On the Mini toolbar that appears when you right-click a range or a cell
•From the Format Cells dialog box
In addition, many common formatting commands have keyboard shortcuts that you can use.
Cross-Reference
Excel also enables you to format cells based on the cell’s contents. Chapter 20 discusses conditional formatting. n
Using the formatting tools of the Home Tab
The Home tab of the Ribbon provides quick access to the most commonly used formatting options. Start by selecting the cell or range; then use the appropriate tool in the Font, Alignment, or Number groups.
Using these tools is very intuitive, and the best way to familiarize yourself with them is to experiment. Enter some data, select some cells, and then click the controls to change the appearance. Note that some of these controls are actually drop-down lists. Click the small arrow on the button, and the button expands to display your choices.
Using the Mini toolbar
When you right-click a cell or a range selection, you get a shortcut menu. In addition, the Mini toolbar appears above the shortcut menu. Figure 6.2 shows how this toolbar looks.
116
Chapter 6: Worksheet Formatting
FIGURE 6.2
The Mini toolbar appears above the right-click shortcut menu.
The Mini toolbar contains controls for common formatting:
•Font
•Font Size
•Increase Font
•Decrease Font
•Accounting Number Format
•Percent Style
•Comma Style
•Format Painter
•Bold
•Italic
•Center
•Borders
•Fill Color
•Font Color
•Increase Decimal
•Decrease Decimal
•Merge & Center
117
Part I: Getting Started with Excel
If you use a tool on the Mini toolbar, the shortcut menu disappears, but the toolbar remains visible so you can apply other formatting if you like. Also, notice that after you use it, the Mini toolbar gradually fades away if you move the mouse pointer away from it. To hide the Mini toolbar, just click in any cell.
Some people find the Mini toolbar distracting. Unfortunately, Excel does not provide an option to turn it off. The Excel Options dialog box does offer the Show Mini Toolbar on Selection option, but this option applies only to selecting text while editing a cell.
Tip
If you really want to disable the Mini toolbar, you can execute this VBA statement in the Immediate window of the Visual Basic Editor (VBE):
Application.ShowMenuFloaties = True
Yes, setting the property to True is completely counter-intuitive! But it works. You need to execute this statement only one time, and Excel remembers the setting between sessions. If you change your mind, execute that statement again, but change True to False.
Using the Format Cells dialog box
The formatting controls available on the Home tab of the Ribbon are sufficient most of the time, but some types of formatting require that you use the Format Cells dialog box. This tabbed dialog box lets you apply nearly any type of stylistic formatting, as well as number formatting. The formats that you choose in the Format Cells dialog box apply to the cells that you have selected at the time. Later sections in this chapter cover the tabs of the Format Cells dialog box.
Note
When you use the Format Cells dialog box, you don’t see the effects of your formatting choices until you click OK. n
After selecting the cell or range to format, you can display the Format Cells dialog box by using any of the following methods:
•Press Ctrl+1.
•Click the dialog box launcher in Home Font, Home Alignment, or Home Number. (The dialog box launcher is the small downward-pointing arrow icon displayed to the right of the group name in the Ribbon.) When you display the Format Cells dialog box using a dialog box launcher, the dialog box is displayed with the appropriate tab visible.
•Right-click the selected cell or range and choose Format Cells from the shortcut menu.
•Click the More command in some of the drop-down controls in the Ribbon. For example, the Home Font Border More Borders drop-down includes an item named More Borders.
The Format Cells dialog box contains six tabs: Number, Alignment, Font, Border, Patterns, and Protection. The following sections contain more information about the formatting options available in this dialog box.
118
Chapter 6: Worksheet Formatting
Using Different Fonts to Format
Your Worksheet
You can use different fonts, sizes, or text attributes in your worksheets to make various parts — such as the headers for a table — stand out. You also can adjust the font size. For example, using a smaller font allows for more information on a single page.
By default, Excel uses 11 point (pt) Calibri font. A font is described by its typeface (Calibri, Cambria, Arial, Times New Roman, Courier New, and so on), as well as by its size, measured in points. (Seventy-two pt equal one inch.) Excel’s row height, by default, is 15 pt. Therefore, 11 pt type entered into 15 pt rows leaves a small amount of blank space between the characters in adjacent rows.
Tip
If you’ve not manually changed a row’s height, Excel automatically adjusts the row height based on the tallest text that you enter into the row. n
Updating Old Fonts
Office 2007 introduced several new fonts, and the default font has been changed for all the Office applications. In versions prior to Excel 2007, the default font was 10 pt Arial. In Excel 2007 and Excel 2010, the default font for the Office theme is 11 pt Calibri. Most people will agree that Calibri is much easier to read, and it gives the worksheet a more modern appearance.
If you open a workbook created in a pre-Excel 2007 version, the default font will not be changed, even if you apply a document style (by choosing Page Layout Themes Themes). But here’s an easy way to update the fonts in a workbook that was created using an older version of Excel:
1.Press Ctrl+N to open a new, empty workbook. The new workbook will use the default document theme.
2.Open your old workbook file.
3.Choose Home Styles Cell Styles Merge Styles. Excel displays its Merge Styles dialog box.
4.In the Merge Styles dialog box, select the new workbook that you created in Step 1.
5.Click OK.
6.Click Yes in response to Excel’s question regarding merging styles that have the same name.
This technique changes the font and size for all unformatted cells. If you’ve applied font formatting to some cells (for example, made them bold), the font for those cells will not be changed (but you can change the font manually). If you don’t like the new look of your workbook, just close the workbook without saving the changes.
119
Part I: Getting Started with Excel
Tip
If you plan to distribute a workbook to other users, you should stick with the standard fonts that are included with Windows or Microsoft Office. If you open a workbook and your system doesn’t have the font with which the workbook was created, Windows attempts to use a similar font. Sometimes this attempt works okay, and sometimes it doesn’t. n
Use the Font and Font Size tools on the Home tab of the Ribbon (or on the Mini toolbar) to change the font or size for selected cells.
You also can use the Font tab in the Format Cells dialog box to choose fonts, as shown in Figure 6.3. This tab enables you to control several other font attributes that aren’t available elsewhere. Besides choosing the font, you can change the font style (bold, italic), underlining, color, and effects (strikethrough, superscript, or subscript). If you select the Normal Font check box, Excel displays the selections for the font defined for the Normal style. I discuss styles later in this chapter. See “Using Named Styles for Easier Formatting.”
FIGURE 6.3
The Font tab of the Format Cells dialog box gives you many additional font attribute options.
Figure 6.4 shows several different examples of font formatting. In this figure, gridlines were turned off to make the underlining more visible. Notice, in the figure, that Excel provides four different underlining styles. In the two non-accounting underline styles, only the cell contents are underlined. In the two accounting underline styles, the entire width of the cells is always underlined.
120
Chapter 6: Worksheet Formatting
FIGURE 6.4
You can choose many different font-formatting options for your worksheets.
If you prefer to keep your hands on the keyboard, you can use the following shortcut keys to format a selected range quickly:
•Ctrl+B: Bold
•Ctrl+I: Italic
•Ctrl+U: Underline
•Ctrl+5: Strikethrough
These shortcut keys act as a toggle. For example, you can turn bold on and off by repeatedly pressing Ctrl+B.
Note
Beginning with Excel 2007, the Document Themes feature attempts to assist nondesigners in creating attractive worksheets. I discuss document themes later in this chapter. See “Understanding Document Themes.” n
Using Multiple Formatting Styles in a Single Cell
If a cell contains text (as opposed to a value or a formula), Excel also enables you to format individual characters in the cell. To do so, switch to Edit mode (press F2, or double-click the cell) and then select the characters that you want to format. You can select characters either by dragging the mouse over them or by pressing the Shift key as you press the leftor right-arrow key.
After you select the characters for format, use any of the standard formatting techniques. The changes apply only to the selected characters in the cell. This technique doesn’t work with cells that contain values or formulas.
121