- •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 8: Using and Creating Templates
When you open a XLST (or *.XLT) template file, you are opening the actual file — you are not creating a workbook from the template file.
Note
To create a workbook from a modified template, you must select the template from the My Templates icon in the Available Template screen. Clicking My Templates displays the New dialog box shown in Figure 8.4. Just select the template and click OK. n
FIGURE 8.4
The New dialog box displays downloaded and custom templates stored on your hard drive.
Understanding Custom Excel Templates
So far, this chapter has focused on templates that were created by others. The remainder of the chapter deals with custom templates — templates that you create.
Why create custom templates? The main reason is to make your job easier. For example, you may always like to use a particular header or footer on your printouts. Consequently, the first time that you print a worksheet, you need to spend time entering the header and footer information.
Although it isn’t a lot of work, wouldn’t it be easier if Excel simply remembered your favorite page settings and used them automatically?
The solution is to modify the template that Excel uses to create new workbooks. In this case, the modification consists of inserting your header into the template. Save the template file using a special name, and then every new workbook that you create (including the workbook created when Excel starts) has your customized page settings.
165
Part I: Getting Started with Excel
Excel supports three types of templates, which I discuss in the following sections:
•The default workbook template: Used as the basis for new workbooks.
•The default worksheet template: Used as the basis for new worksheets inserted into a workbook.
•Custom workbook templates: Usually, these ready-to-run workbooks include formulas, but they can be as simple or as complex as you like. Typically, these templates are set up so that a user can simply plug in values and get immediate results. The Microsoft Office Online templates (discussed earlier in this chapter) are examples of this type of template.
Working with the default templates
The term default template may be a little misleading. If you haven’t created your own template files to control the default settings, Excel uses its own internal settings — not an actual template file.
In other words, Excel uses your template files to set the defaults for new workbooks or worksheets, if these files exist. But if you haven’t created these files, Excel is perfectly happy to use its own settings.
Using the workbook template to change workbook defaults
Every new workbook that you create starts out with some default settings. For example, the workbook has three worksheets, the worksheets have gridlines, the page header and footer are blank, and text appears in the fonts specified by the default document template. Columns are 8.43 units wide, and so on. If you’re not happy with any of the default workbook settings, you can change them by creating a workbook template.
Making changes to Excel’s default workbook is fairly easy to do, and it can save you lots of time in the long run. Here’s how you change Excel’s workbook defaults:
1.Open a new workbook.
2.Add or delete sheets to give the workbook the number of worksheets that you want.
3.Make any other changes that you want to make, which can include column widths, named styles, page setup options, and many of the settings that are available in the Excel Options dialog box. To change the default formatting for cells, choose
Home Styles Cell Styles and then modify the settings for the Normal style. For example, you can change the default font, size, or number format.
4.When your workbook is set up to your liking, choose File Save As.
5.In the Save As dialog box, select Excel Template (*.xltx) from the Save As Type list.
If your template contains any VBA macros, select Excel Macro-Enabled Template (*.xltm).
6.Enter book for the filename.
166
Chapter 8: Using and Creating Templates
Caution
Excel will offer a name, such as Book1.xlt. You must change this name to book.xlt (or book.xltm) if you want Excel to use your template to set the workbook defaults. n
7. Save the file in your XLStart folder (not in your Templates folder).
Tip
The location of the XLStart folder varies, but it is probably located here:
C:\Program Files\Microsoft Office\Office14\XLStart
8. Close the file.
After you perform the preceding steps, the new default workbook is based on the book.xltx (or book.xltm) workbook template. You can create a workbook based on your template by using any of these methods:
•Press Ctrl+N.
•Open Excel without first selecting a workbook to open.
Note
For some reason, the book.xltx template is not used if you choose File New and choose Blank Workbook.
That command results in a default workbook. I’m not sure whether this is a bug or whether it’s by design. In any case, it provides a way to override the custom book.xltx template if you need to. n
Caution
If you insert a new worksheet into a workbook that’s based on the book.xlxt template, the new worksheet will not use any customized worksheet settings specified in the template (for example, a different column width). Therefore, you may also want to create a sheet.xltx template (described in the next section), which controls the settings for new worksheets. n
If you ever want to revert to the standard default workbook, just delete the book.xltx file.
Using the worksheet template to change worksheet defaults
When you insert a new worksheet into a workbook, Excel uses its built-in worksheet defaults for the worksheet. These default settings include items such as column width, row height, and so on.
If you don’t like the default settings for a new worksheet, you can change them by following these steps:
1.Start with a new workbook and delete all the sheets except one.
2.Make any changes that you want to make, which can include column widths, named styles, page setup options, and many settings available in the Excel Options dialog box.
167
Part I: Getting Started with Excel
3.When your workbook is set up to your liking, choose File Save As.
4.In the Save As dialog box, select Template (*.xltx) from the Save As Type list.
5.Enter sheet.xltx for the filename.
6.Save the file in your \XLStart folder (not in your \Templates folder).
7.Close the file.
8.Close and restart Excel.
After performing these steps, all new worksheets that you insert by using any of these methods will be formatted like your sheet.xltx template:
•Click the Insert Worksheet button (next to the last sheet tab).
•Choose Home Cells Insert Insert Sheet.
•Press Shift+F11.
•Right-click a sheet tab, choose Insert from the shortcut menu, and choose the Worksheet icon in the Insert dialog box.
Editing your templates
After you create your book.xltx or sheet.xltx templates, you may discover that you need to change them. You can open the template files and edit them just like any other workbook. After you make your changes, save the file to its original location, and close it.
Resetting the default workbook and worksheet settings
If you create a book.xltx or sheet.xltx file and then decide that you would rather use the standard default settings, simply delete the book.xltx or sheet.xltx template file — depending on whether you want to use the standard workbook or worksheet defaults — from the XLStart folder. Excel then uses its built-in default settings for new workbooks or worksheets.
Tip
You can also rename or move the template files if you’d like to keep them for future use. n
Creating custom templates
The book.xltx and sheet.xltx templates discussed in the preceding section are two special types of templates that determine default settings for new workbooks and new worksheets. This section discusses other types of templates, referred to as workbook templates, which are simply workbooks that you set up as the basis for new workbooks or worksheets.
Creating a workbook template can eliminate repeating work. Assume that you create a monthly sales report that consists of your company’s sales by region, plus several summary calculations and charts. You can create a template file that consists of everything except the input values. Then, when it’s time to create your report, you can open a workbook based on the template, fill in the blanks, and be finished.
168
Chapter 8: Using and Creating Templates
Note
You could, of course, just use the previous month’s workbook and save it with a different name. This is prone to errors, however, because you easily can forget to use the Save As command and accidentally overwrite the previous month’s file. Another option is to use File New, and choose the New from Existing option in the
Available Templates screen. This command creates a new workbook from an existing one, but gives a different name to ensure that the old file is not overwritten. n
When you create a workbook that’s based on a template, the default workbook name is the template name with a number appended. For example, if you create a new workbook based on a template named Sales Report.xltx, the workbook’s default name is Sales Report1.xlsx. The first time that you save a workbook that is created from a template, Excel displays its Save As dialog box so that you can give the template a new name if you want to.
A custom template is essentially a normal workbook, and it can use any Excel feature, such as charts, formulas, and macros. Usually, a template is set up so that the user can enter values and get immediate results. In other words, most templates include everything but the data, which is entered by the user.
Note
If your template contains macros, it must be saved as an Excel Macro-Enabled Template, with an XLTM extension. n
Locking Formula Cells in a Template File
If novices will use the template, you might consider locking all the formula cells to make sure that the formulas aren’t deleted or modified. By default, all cells are locked and cannot be changed when the worksheet is protected. The following steps describe how to unlock the nonformula cells:
1.Choose Home Editing Find & Select Go to Special to display the Go To Special dialog box.
2.Select Constants and click OK. This step selects all nonformula cells.
3.Press Ctrl+1 to display the Format Cells dialog box.
4.In the Format Cells dialog box, click the Protection tab.
5.Remove the check mark from the Locked check box.
6.Click OK to close the Format Cells dialog box.
7.Choose Review Changes Protect Sheet to display the Protect Sheet dialog box.
8.Specify a password (optional) and then click OK.
After you perform these steps, you can’t modify the formula cells — unless the sheet is unprotected.
169
Part I: Getting Started with Excel
Saving your custom templates
To save a workbook as a template, choose File Save As and select Template (*.xltx) from the Save as Type drop-down list. If the workbook contains any VBA macros, select Excel MacroEnabled Template (*.xltm). Save the template in your Templates folder — which Excel automatically suggests — or a folder within that Templates folder.
If you later discover that you want to modify the template, choose File Open to open and edit the template.
Ideas for creating templates
This section provides a few ideas that may spark your imagination for creating templates. The following is a partial list of the settings that you can adjust and use in your custom templates:
•Multiple formatted worksheets: You can, for example, create a workbook template that has two worksheets — one formatted to print in landscape mode and one formatted to print in portrait mode.
•Style: The best approach is to choose Home Styles Cell Styles and modify the attributes of the Normal style. For example, you can change the font or size, the alignment, and so on.
•Custom number formats: If you create number formats that you use frequently, you can store them in a template.
•Column widths and row heights: You may prefer that columns be wider or narrower, or you may want the rows to be taller.
•Print settings: Change these settings in the Page Layout tab. You can adjust the page orientation, paper size, margins, and several other attributes.
•Header and footer: You enter custom headers or footers in Page Layout view (choose View Workbook Views Page Layout).
•Sheet settings: These options are in the Show group on the View tab, and also on the Advanced tab of the Excel Options dialog box (in the Display Options for This Worksheet section). Options include row and column header, page break display, gridlines, and others.
You can, of course, also create complete workbooks and save them as templates. For example, if you frequently need to produce a specific report, you may want to create a template that has everything for the report except for the data you need to enter. By saving your master copy as a template, you’re less likely to overwrite the original file when you save the file after entering your data.
170