- •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 27: Linking and Consolidating Worksheets
The following link formula refers to cell C21 on Sheet1 in the budget.xlsx workbook:
=[budget.xlsx]Sheet1!$C$21
If cell C21 is named Total, you can write the formula using that name:
=budget.xlsx!total
Using a name ensures that the link retrieves the correct value, even if you add or delete rows or columns from the source workbook.
Cross-Reference
See Chapter 4 for more information about creating names for cells and ranges. n
Intermediary links
Excel doesn’t place many limitations on the complexity of your network of external references. For example, Workbook A can contain external references that refer to Workbook B, which can contain an external reference that refers to Workbook C. In this case, a value in Workbook A can ultimately depend on a value in Workbook C. Workbook B is an intermediary link.
I don’t recommend using intermediary links, but if you must use them, be aware that Excel doesn’t update external reference formulas if the dependent workbook isn’t open. In the preceding example, assume that Workbooks A and C are open. If you change a value in Workbook C, Workbook A won’t reflect the change because you didn’t open Workbook B (the intermediary link).
Consolidating Worksheets
The term consolidation, in the context of worksheets, refers to several operations that involve multiple worksheets or multiple workbook files. In some cases, consolidation involves creating link formulas. Here are two common examples of consolidation:
•The budget for each department in your company is stored in a single workbook, with a separate worksheet for each department. You need to consolidate the data and create a company-wide budget on a single sheet.
•Each department head submits a budget to you in a separate workbook file. Your job is to consolidate these files into a company-wide budget.
These types of tasks can be very difficult or quite easy. The task is easy if the information is laid out exactly the same in each worksheet. If the worksheets aren’t laid out identically, they may be similar enough. In the second example, some budget files submitted to you may be missing categories that aren’t used by a particular department. In this case, you can use a handy feature in Excel that matches data by using row and column titles. I discuss this feature in “Consolidating worksheets by using the Consolidate command,” later in this chapter.
597
Part IV: Using Advanced Excel Features
If the worksheets bear little or no resemblance to each other, your best bet may be to edit the sheets so that they correspond to one another. Better yet, return the files to the department heads and ask that they submit them using a standardized format.
You can use any of the following techniques to consolidate information from multiple workbooks:
•Use external reference formulas.
•Copy the data and choose Home Clipboard Paste Paste Link (N).
•Use the Consolidate dialog box, displayed by choosing Data Data Tools Consolidate.
Consolidating worksheets by using formulas
Consolidating with formulas simply involves creating formulas that use references to other worksheets or other workbooks. The primary advantages to using this method of consolidation are
•Dynamic updating: If the values in the source worksheets change, the formulas are updated automatically.
•Open versus closed: The source workbooks don’t need to be open when you create the consolidation formulas.
If you’re consolidating the worksheets in the same workbook and all the worksheets are laid out identically, the consolidation task is simple. You can just use standard formulas to create the consolidations. For example, to compute the total for cell A1 in worksheets named Sheet2 through Sheet10, enter the following formula:
=SUM(Sheet2:Sheet10!A1)
You can enter this formula manually or use the multisheet selection technique discussed in Chapter 4. You can then copy this formula to create summary formulas for other cells.
If the consolidation involves other workbooks, you can use external reference formulas to perform your consolidation. For example, if you want to add the values in cell A1 from Sheet1 in two workbooks (named Region1 and Region2), you can use the following formula:
=[Region1.xlsx]Sheet1!B2+[Region2.xlsx]Sheet1!B2
You can include any number of external references in this formula, up to the 8,000-character limit for a formula. However, if you use many external references, such a formula can be quite lengthy and confusing if you need to edit it.
If the worksheets that you’re consolidating aren’t laid out the same, you can still use formulas, but you need to ensure that each formula refers to the correct cell.
598
Chapter 27: Linking and Consolidating Worksheets
Consolidating worksheets by using Paste Special
Another method of consolidating information is to use the Paste Special dialog box. This technique takes advantage of the fact that the Paste Special dialog box can perform a mathematical operation when it pastes data from the Clipboard. For example, you can use the Add option to add the copied data to the selected range. Figure 27.5 shows the Paste Special dialog box.
This method is applicable only when all the worksheets that you’re consolidating are open. The disadvantage is that the consolidation isn’t dynamic. In other words, it doesn’t generate formulas. So, if any data that was consolidated changes, the consolidation is no longer accurate.
FIGURE 27.5
Choosing the Add operation in the Paste Special dialog box.
Here’s how to use this method:
1.Copy the data from the first source range.
2.Activate the dependent workbook and select a location for the consolidated data.
A single cell is sufficient.
3.Display the Paste Special dialog box (choose Home Clipboard Paste Paste
Special).
4.Choose the Values option and the Add operation, and then click OK.
Repeat these steps for each source range that you want to consolidate. Make sure that the consolidation location in Step 2 is the same for each paste operation.
Caution
This method is probably the worst way of consolidating data. It can be rather error prone, and the lack of formulas means that you have no way to verify the accuracy of the data. n
599
Part IV: Using Advanced Excel Features
Consolidating worksheets by using the Consolidate command
For the ultimate in data consolidation, use the Consolidate dialog box. This method is very flexible, and in some cases, it even works if the source worksheets aren’t laid out identically. This technique can create consolidations that are static (no link formulas) or dynamic (with link formulas). The Data Consolidate feature supports the following methods of consolidation:
•By position: This method is accurate only if the worksheets are laid out identically.
•By category: Excel uses row and column labels to match data in the source worksheets. Use this option if the data is laid out differently in the source worksheets or if some source worksheets are missing rows or columns.
Figure 27.6 shows the Consolidate dialog box, which appears when you choose Data Data Tools Consolidate. Following is a description of the controls in this dialog box:
FIGURE 27.6
The Consolidate dialog box enables you to specify ranges to consolidate.
•Function drop-down list: Specify the type of consolidation. Sum is the most commonly used consolidation function, but you also can select from ten other options.
•Reference text box: Specify a range from a source file that you want to consolidate. You can enter the range reference manually or use any standard pointing technique (if the workbook is open). Named ranges are also acceptable. After you enter the range in this box, click Add to add it to the All References list. If you consolidate by position, don’t include labels in the range. If you consolidate by category, do include labels in the range.
•All References list box: Contains the list of references that you have added with the Add button.
600
Chapter 27: Linking and Consolidating Worksheets
•Use Labels In check boxes: Use to instruct Excel to perform the consolidation by examining the labels in the top row, the left column, or both positions. Use these options when you consolidate by category.
•Create Links to Source Data check box: When you select this option, Excel adds summary formulas for each label and creates an outline. If you don’t select this option, the consolidation doesn’t use formulas, and an outline isn’t created.
•Browse button: Click to display a dialog box that enables you to select a workbook to open. It inserts the filename in the Reference box, but you have to supply the range reference. You’ll find that your job is much easier if all the workbooks to be consolidated are open.
•Add button: Click to add the reference in the Reference box to the All References list. Make sure that you click this button after you specify each range.
•Delete button: Click to delete the selected reference from the All References list.
A workbook consolidation example
The simple example in this section demonstrates the power of the Data Consolidate feature. Figure 27.7 shows three single-sheet workbooks that will be consolidated. These worksheets report product sales for three months. Notice, however, that they don’t all report on the same products. In addition, the products aren’t even listed in the same order. In other words, these worksheets aren’t laid out identically. Creating consolidation formulas manually would be a very tedious task.
FIGURE 27.7
Three worksheets to be consolidated.
601
Part IV: Using Advanced Excel Features
On the CD
These workbooks are available on the companion CD-ROM. The files are named region1.xlsx, region2. xlsx, and region3.xlsx.
To consolidate this information, start with a new workbook. You don’t need to open the source workbooks, but consolidation is easier if they are open. Follow these steps to consolidate the workbooks:
1.Choose Data Data Tools Consolidate. Excel displays its Consolidate dialog box.
2.Use the Function drop-down list to select the type of consolidation summary that you want to use. Use Sum for this example.
3.Enter the reference for the first worksheet to consolidate. If the workbook is open, you can point to the reference. If it’s not open, click the Browse button to locate the file on disk. The reference must include a range. You can use a range that includes complete columns, such as A:K. This range is larger than the actual range to consolidate, but using this range ensures that the consolidation will still work if new rows and columns are added to the source file. When the reference in the Reference box is correct, click Add to add it to the All References list.
4.Enter the reference for the second worksheet. You can point to the range in the Region2 workbook, or you can simply edit the existing reference by changing Region1 to Region2 and then clicking Add. This reference is added to the All References list.
5.Enter the reference for the third worksheet. Again, you can edit the existing reference by changing Region2 to Region3 and then clicking Add. This final reference is added to the All References list.
6.Because the worksheets aren’t laid out the same, select the Left Column and the Top Row check boxes to force Excel to match the data by using the labels.
7.Select the Create Links to Source Data check box to make Excel create an outline with external references.
8.Click OK to begin the consolidation.
Excel creates the consolidation, beginning at the active cell. Notice that Excel created an outline, which is collapsed to show only the subtotals for each product. If you expand the outline (by clicking the number 2 or the + symbols in the outline), you can see the details. Examine it further, and you discover that each detail cell is an external reference formula that uses the appropriate cell in the source file. Therefore, the consolidated results are updated automatically values are changed in any of the source workbooks.
Figure 27.8 shows the result of the consolidation, and Figure 27.9 shows the summary information (with the outline collapsed to hide the details).
Cross-Reference
For more information about Excel outlines, see Chapter 26. n
602
Chapter 27: Linking and Consolidating Worksheets
FIGURE 27.8
The result of consolidating the information in three workbooks.
FIGURE 27.9
Collapsing the outline to show only the totals.
603
Part IV: Using Advanced Excel Features
Refreshing a consolidation
When you choose the option to create formulas, the external references in the consolidation workbook are created only for data that exists at the time of the consolidation. Therefore, if new rows are added to any of the original workbooks, the consolidation must be re-done. Fortunately, the consolidation parameters are stored with the workbook, so it’s a simple matter to re-run the consolidation if necessary. That’s why specifying complete columns and including extra columns (in Step 3 in the preceding section) is a good idea.
Excel remembers the references that you entered in the Consolidate dialog box and saves them with the workbook. That way, if you want to refresh a consolidation, you won’t have to re-enter the references. Just display the Consolidate dialog box, verify that the ranges are correct, and then click OK.
More about consolidation
Excel is very flexible regarding the sources that you can consolidate. You can consolidate data from the following:
•Open workbooks
•Closed workbooks. You need to enter the reference manually, but you can use the Browse button to get the filename part of the reference.
•The same workbook in which you’re creating the consolidation
And, of course, you can mix and match any of the preceding choices in a single consolidation.
If you perform the consolidation by matching labels, be aware that the matches must be exact. For example, Jan doesn’t match January. The matching is not case sensitive, however, so April does match APRIL. In addition, the labels can be in any order, and they don’t need to be in the same order in all the source ranges.
If you don’t select the Create Links to Source Data check box, Excel generates a static consolidation. (It doesn’t create formulas.) Therefore, if the data on any of the source worksheets changes, the consolidation won’t update automatically. To update the summary information, you need to choose Data Data Tools Consolidate again.
If you do select the Create Links to Source Data check box, Excel creates a standard worksheet outline that you can manipulate by using the techniques described in Chapter 26.
604
CHAPTER
Excel and the Internet
Most people who use a computer are connected to the Internet. The Web has become an important way to share and gather information from myriad sources. To help you with these tasks, Excel has
the capability to create files that you can use on the Internet and also to gather and process data from the Web. This chapter covers topics related to Excel and the Internet.
Note
Four of the Office 2010 applications are available in online versions: Excel, Word, PowerPoint, and OneNote. You can run these applications from within your Web browser. The online version of Excel is not the topic of this chapter, and is not covered in this book. Rather, the chapter deals with Internet-related features for the standard version of Excel. n
Understanding How
Excel Uses HTML
HTML (HyperText Markup Language) is the language of the World Wide Web. When you browse the Web, most documents that your browser retrieves and displays are in HTML format. An HTML file consists of text information plus special tags that describe how the text is to be formatted. The browser interprets the tags, applies the formatting, and displays the information.
IN THIS CHAPTER
Saving Excel files in HTML format
Creating hyperlinks
Importing data from a Web page
605