Excel 2003 bible

938
Harness XML power for data reporting, analysis, importing, and exporting Discover how Excel can support reports, presentations, record-keeping, and more Explore advanced Excel programming techniques with the top spreadsheet authority E xcel 2003 John Walkenbach 100% ONE HUNDRED PERCENT COMPREHENSIVE AUTHORITATIVE WHAT YOU NEED ONE HUNDRED PERCENT E xcel 2003 “Mr. Spreadsheet,” author of Excel Charts BONUS CD-ROM AND COMPANION WEB SITE More than 600MB of Office-compatible bonus software and eBooks included on the CD! Microsoft O ce Microsoft O ce ® ®

description

 

Transcript of Excel 2003 bible

  • 1. 539671 Cover_rb.qxp 8/22/03 10:00 AM Page 1 Perfect Bind Trim: 7 3/8 x 9 1/4 4 color process Yellow prints 110y 15m + spot varnish (see spot varnish pdf) Matte laminate If Excel 2003 can do it, you can do it too . . . Whether youre just discovering Excel or are already a power user, theres no better instructor than Mr. Spreadsheet, John Walkenbach. From basic formulas, functions, and chart creation to data analysis, custom 100% C O M P R E H E N S I V E 100% ONE HUNDRED PERCENT number formats, data validation, and Excel programming with VBA, this is the comprehensive resource forCOMPREHENSIVEExcel 2003Excel 2003AUTHORITATIVE Excel 2003. No matter what your level of expertise, youll benefit from hundreds of examples, exercises, tips, WHAT YOU NEED techniques, and workarounds, all served with a generous helping of the masters expert advice.ONE HUNDRED PERCENT Microsoft Oce Microsoft Oce Inside, youll find complete coverage of Excel 2003Harness XML power Learn your way around cells, rows, columns, worksheets, workbooks, and rangesfor data reporting, Discover how to create charts and diagrams, organize lists, and simplify complex tasks using Excel analysis, importing,and exporting Develop formulas that manipulate text, look up values, and perform financial applications Analyze data using external database files and pivot tablesDiscover how Excel Perform what if analysis, use Goal Seek and Solver, and gain proficiency with the Analysis ToolPak can support reports,presentations, Use XML to facilitate data reporting, analysis, importing, and exportingrecord-keeping, and Explore conditional formatting, link and consolidate worksheets, more and use Excel in a workgroup Understand how Excel uses HTML in Internet applicationsExplore advancedExcel programming Program Excel using VBA, develop UserForms, and create custom add-instechniques with theChart your data top spreadsheetBonus CD-ROM and companion Web site!effectively authorityE Exclusive Office 2003 Super Bible eBook, with more than 500 pages of information aboutxcel 2003 how Microsoft Office components work together Bonus shareware, freeware, trial, demo, and evaluation programs that work with or enhance Microsoft Office Microsoft Oce Searchable eBook version of Excel 2003 Bible An easy-to-use interface that allows you to browse and install everything on the CD Visit the companion Web site for links to all programs on the CD as well as additional software, complete tables of contents for all seven Wiley Office 2003 Bibles, and links to other Wiley Microsoft Office titles.WALKENBACH www.wiley.com/compbooks/officebibles2003 System Requirements: See the CD appendix for details and complete $39.99 USA $59.99 Canada Reader Level: Beginning to AdvancedShelving Category:Computers/SpreadsheetsBibleBonus software system requirements.27.95 UK and searchable eBooks on ISBN 0-7645-3967-1 CD-ROM*85 5 -IGIE b,!7IA7G4-fdjghb!:p;N;t;T;t BONUS CD-ROM ANDCOMPANION WEB SITEMore than 600MB of Office-compatiblebonus software and eBooks included on the CD!John WalkenbachMr. Spreadsheet, author of Excel Charts

2. Digitally signed by Ramanathan DN: cn=Ramanathan, c=IN, o=Commercial Taxed DeptRamanathan Staff Training Institute,, ou=Computer Lecturer,, [email protected] Location: Commercial Taxes Staff Training Institute, Computer Lecturer,Ph:9442282076 Date: 2008.03.20 17:54:02 +0530 3. 01 539671 FM.qxd 8/28/03 9:59 AM Page iDigitally signed by RamanathanRamanathanDN: cn=Ramanathan, c=IN, o=Commercial Taxed Dept StaffTraining Institute,, ou=Computer Lecturer,, [email protected]: Commercial Taxes Staff Training Institute, ComputerLecturer,Ph:9442282076Date: 2008.03.20 17:54:52 +0530 Excel 2003 Bible 4. 01 539671 FM.qxd 8/28/03 9:59 AM Page ii 5. 01 539671 FM.qxd 8/28/03 9:59 AM Page iiiDigitally signed by RamanathanDN: cn=Ramanathan, c=IN, o=Commercial Taxed Dept StaffRamanathanTraining Institute,, ou=Computer Lecturer,, [email protected]: Commercial Taxes Staff Training Institute, ComputerLecturer,Ph:9442282076Date: 2008.03.20 17:55:25 +0530 Excel 2003 Bible John Walkenbach 6. 01 539671 FM.qxd8/28/03 9:59 AM Page iv Excel 2003 Bible Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright 2003 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 0-7645-3967-1 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/RY/QZ/QT/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8700. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail: [email protected] OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BESTEFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THEACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIEDWARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATEDOR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ADVICE AND STRATEGIESCONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH APROFESSIONAL WHERE APPROPRIATE. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSSOF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL,CONSEQUENTIAL, OR OTHER DAMAGES. FULFILLMENT OF EACH COUPON OFFER IS THE SOLE RESPONSIBILITY OFTHE OFFEROR. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2003101915 Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. is a trademark of Wiley Publishing, Inc. 7. 01 539671 FM.qxd 8/28/03 9:59 AM Page vAbout the AuthorJohn Walkenbach is the author of approximately three dozen spreadsheet books.Visit his Web site at http://.j-walk.com. 8. 01 539671 FM.qxd 8/28/03 9:59 AM Page viCreditsAcquisitions Manager Project CoordinatorGregory S. CroyErin SmithProject Editor Graphics and Production SpecialistsLinda Morris Carrie Foster LeAndra HosierTechnical Editor Michael KruzilBill ManvilleLynsey Osborn Heather PopeSenior Copy Editor Mary Gillot VirginDiana R. Conover Quality Control TechniciansEditorial ManagerLaura AlbertKevin KirschnerSusan Moritz Carl William PierceVice President & Executive Group Brian H. WallsPublisherRichard SwadleySenior Permissions Editor Carmen KrikorianVice President and PublisherAndy CummingsMedia Development Specialist Greg StaffordEditorial DirectorMary C. Corder Proofreading and Indexing TECHBOOKS Production Services 9. 01 539671 FM.qxd 8/28/03 9:59 AM Page viiPrefaceT hanks for purchasing the Excel 2003 Bible. My goal in writing this book is toshare with you some of what I know about Excel, and in the process, make youmore efficient on the job.The book contains everything that you need to know to learn the basics of Exceland then move on to more advanced topics at your own pace. Youll find many use-ful examples and lots of tips and tricks that Ive accumulated over the years.Is This Book for You?The Bible series from Wiley Publishing, Inc. is designed for beginning, intermediate,and advanced users. This book covers all the essential components of Excel andprovides clear and practical examples that you can adapt to your own needs.In this book, Ive tried to maintain a good balance between the basics that everyExcel user needs to know and the more complex topics that will appeal to powerusers. Ive used Excel for many years, and I realize that almost everyone still hassomething to learn (including myself). My goal is to make that learning an enjoyableprocess.Software VersionsThis book was written for Excel 2003 for Windows. However, Excel hasnt reallychanged much lately, so most of the information also applies to earlier versions andalso to the Macintosh version. If you use a version prior to Excel 97, youll find thata significant portion of this book does not apply. 10. 01 539671 FM.qxd 8/28/039:59 AMPage viiiviiiPrefaceConventions This Book UsesTake a minute to scan this section to learn some of the typographical and organiza-tional conventions that this book uses.Excel commandsIn Excel, as in all Windows programs, you select commands from the pull-downmenu system. In this book, such commands appear in normal typeface. An optionavailable under a particular menu is indicated after an symbol, as in ChooseFile Print to print your document.Filenames, named ranges, and your inputInput that you make from the keyboard appears in bold. Named ranges may appearin a code font. Lengthy input usually appears on a separate line. For instance, Imay instruct you to enter a formula such as the following:=Part Name: &VLOOKUP(PartNumber,PartList,2)Key namesNames of the keys on your keyboard appear in normal type. When two keys should bepressed simultaneously, they are connected with a plus sign, like this: Press Alt+E toselect the Edit menu. Here are the key names as I refer to them throughout the book: Altdown arrow Num Lockright arrow BackspaceEndPause Scroll Lock Caps LockHome PgDnShift Ctrl Insert PgUpTab Delete left arrow Print Screenup arrowFunctionsExcels built-in worksheet functions appear in uppercase, like this: Enter a SUM for-mula in cell C20.Mouse conventionsYoull come across some of the following mouse-related terms, all standard fare: 11. 01 539671 FM.qxd 8/28/03 9:59 AM Page ixPreface ix Mouse pointer: The small graphic figure that moves onscreen when you move your mouse. The mouse pointer is usually an arrow, but it changes shape when you move to certain areas of the screen or when youre performing cer- tain actions. Point: Move the mouse so that the mouse pointer is on a specific item: for example, Point to the Save button on the toolbar. Press: Press the left mouse button once and keep it pressed. Normally, this is used when dragging. Click: Press the left mouse button once and release it immediately. Right-click: Press the right mouse button once and release it immediately. The right mouse button is used in Excel to pop up shortcut menus that are appro- priate for whatever is currently selected. Double-click: Press the left mouse button twice in rapid succession. If your double-clicking doesnt seem to be working, you can adjust the double-click sensitivity by using the Windows Control Panel icon. Drag: Press the left mouse button and keep it pressed while you move the mouse. Dragging is often used to select a range of cells or to change the size of an object.What the Icons MeanThroughout the book, youll see special graphic symbols, or icons, in the left mar-gin. These call your attention to points that are particularly important or relevantto a specific group of readers. The icons in this book are as follows:Note This icon signals the fact that something is important or worth noting. Notes may alert you to a concept that helps you master the task at hand, or they may denote something that is fundamental to understanding subsequent material. Tip This icon marks a more efficient way of doing something that may not be obvious.CautionI use this symbol when a possibility exists that the operation were describing could cause problems if youre not careful. Cross-This icon indicates that a related topic is discussed elsewhere in the book. Reference 12. 01 539671 FM.qxd 8/28/03 9:59 AMPage xx PrefaceOn theThis icon indicates that a related example or file is available on the companionCD-ROMCD-ROM. NewThis icon indicates a feature that is new to Excel 2003. FeatureHow This Book Is Organized Notice that the book is divided into six main parts, followed by five appendixes. Part I: Getting Started With Excel: This part consists of seven chapters that pro- vide background about Excel. These chapters are considered required reading for Excel newcomers, but even experienced users will probably find some new informa- tion here. Part II: Working with Formulas and Functions: The chapters in Part II cover every- thing that you need to know to become proficient with performing calculations in Excel. Part III: Creating Charts and Graphics: The chapters in Part III describe how to create effective charts as well as use graphics in your workbooks. Part IV: Analyzing Data with Excel: Data analysis is the focus of the chapters in Part IV. Users of all levels will find some of these chapters of interest. Part V: Using Advanced Excel Features: This part consists of nine chapters dealing with topics that are sometimes considered advanced. However, many beginning and intermediate users may find this information useful as well. Part VI: Programming Excel with VBA: Part VI is for those who want to customize Excel for their own use or who are designing workbooks or add-ins that are to be used by others. It starts with an introduction to VBA programming and then pro- vides coverage of UserForms, add-ins, toolbars, menus, and events. Part VII: Appendixes: Part VII contains a wide variety of appendixes that cover everything from Excel worksheet functions, to the contents of the books CD-ROM, to some fun games and diversions created using Excel.How to Use This Book This book is not intended to be read cover to cover. Rather, its a reference book that you can consult when: Youre stuck while trying to do something. You need to do something that youve never done before. 13. 01 539671 FM.qxd 8/28/03 9:59 AM Page xi Preface xi You have some time on your hands, and youre interested in learning some- thing new.The index is comprehensive, and each chapter typically focuses on a single broadtopic. If youre just starting out with Excel, I recommend that you read the first fewchapters to gain a basic understanding of the product and then do some experi-menting on your own. After you become familiar with Excels environment, you canrefer to the chapters that interest you most. Some users, however, may prefer tofollow the chapters in order.Dont be discouraged if some of the material is over your head. Most users get byjust fine by using only a small subset of Excels total capabilities. In fact, the 80/20rule applies here: 80 percent of Excel users use only 20 percent of its features.However, using only 20 percent of Excels features still gives you lots of power atyour fingertips.New Features in Excel 2003This section briefly describes the new features in Excel 2003, relative to Excel 2002.Where applicable, I provide additional details later in this book. Youll notice thatthe list is surprisingly short.XML supportExcel 2003 has improved support for XML (eXtensible Markup Language). Thismeans that you can import XML data and assign the data elements to specific cellsin a worksheet.List rangesYou can define a portion of a workbook as a list range. This may make it a bit easierto work with the list for example, add new items and summary formulas. You canalso export the list range to SharePoint Team Services to share it with others. Thelist on a Web site based on SharePoint Team Services can be linked to the originalrange of cells.Research PaneA new feature, Research Pane, lets you search standard reference books and Websites by using Excels Task Pane.Smart tag improvementsIn the past, smart tags could either be turned on or off. Its now possible to enablesmart tags only for a specified range of cells. 14. 01 539671 FM.qxd 8/28/03 9:59 AM Page xii xiiPrefaceStatistical functionsAdvanced users often complain about the inaccuracy of some of Excels statisticalfunctions. Microsoft claims to have corrected these long-standing problems.Whats on the Companion CD and Web SiteWiley has provided so much add-on value to this book that we couldnt fit it all onone CD! With the purchase of this book, you not only get access to over 200 bonussoftware programs and demos, but you also get an entire eBook free!Please take a few minutes to explore the bonus material included on the CD: Author-created materials: Demonstration and sample files from the book. Bonus software materials: Over 200 programs (shareware, freeware, GNUsoftware, trials, demos, and evaluation software) that work with Office. AReadMe file on the CD includes complete descriptions of each software item. Office 2003 Super Bible eBook: Wiley created this special eBook, consistingof over 500 pages of content about how Microsoft Office components worktogether and with other products. The content has been pulled from selectchapters of the individual Office Bible titles. In addition, some original contenthas been created just for this Super Bible. PDF version of this title: As always, if you prefer your text in electronic for-mat, the CD offers a completely searchable, PDF version of the book that youhold in your hands.After you familiarize yourself with all that we have packed onto the CD, be sure tovisit the companion Web site at www.wiley.com/compbooks/officebibles2003/.Heres what youll find on the Web site: Links to all the software that wouldnt fit onto the CD Links to all the software found on the CD Complete, detailed tables of contents for all the Wiley Office 2003 Bibles:Access 2003 Bible, Excel 2003 Bible, FrontPage 2003 Bible, Office 2003 Bible,Outlook 2003 Bible, PowerPoint Bible, and Word 2003 Bible Links to other Wiley Office titles 15. 01 539671 FM.qxd 8/28/03 9:59 AM Page xiiiContents at a GlancePreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viiPart I: Getting Started with Excel . . . . . . . . . . . . . . . . . . . . . . 1Chapter 1: Introducing Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Chapter 2: Entering and Editing Worksheet Data . . . . . . . . . . . . . . . . . . . 25Chapter 3: Essential Worksheet Operations . . . . . . . . . . . . . . . . . . . . . . 43Chapter 4: Working with Cells and Ranges . . . . . . . . . . . . . . . . . . . . . . . 63Chapter 5: Worksheet Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Chapter 6: Understanding Files and Templates . . . . . . . . . . . . . . . . . . . 105Chapter 7: Printing Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Part II: Working with Formulas and Functions . . . . . . . . . . . . . 139Chapter 8: Introducing Formulas and Functions . . . . . .. . . . . . . . . . . . . 141Chapter 9: Creating Formulas That Manipulate Text . . .. . . . . . . . . . . . . 169Chapter 10: Working with Dates and Times . . . . . . . . . . . . . . . . . . . . . 189Chapter 11: Creating Formulas That Count and Sum . . . . . . . . . . . . . . . . 221Chapter 12: Creating Formulas That Look Up Values . . .. . . . . . . . . . . . . 249Chapter 13: Creating Formulas for Financial Applications . . . . . . . . . . . . . 269Chapter 14: Introducing Array Formulas . . . . . . . . . . . . . . . . . . . . . . . 295Chapter 15: Performing Magic with Array Formulas . . . . . . . . . . . . . . . . 317Part III: Creating Charts and Graphics . . . . . . . . . . . . . . . . . . 337Chapter 16: Getting Started Making Charts . . . . . . . . . . . . . . . . . . . . . 339Chapter 17: Learning Advanced Charting . . . . . . . . . . . . . . . . . . . . . . 373Chapter 18: Enhancing Your Work with Pictures and Drawings . . . . . . . . . . 419Part IV: Analyzing Data with Excel . . . . . . . . . . . . . . . . . . . . 435Chapter 19: Working with Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437Chapter 20: Using External Database Files . . . . . . . .. . . . . . . . . . . . . . 463Chapter 21: Analyzing Data with Pivot Tables . . . . . . . . . . . . . . . . . . . . 479Chapter 22: Performing Spreadsheet What-If Analysis .. . . . . . . . . . . . . . 501Chapter 23: Analyzing Data Using Goal Seek and Solver. . . . . . . . . . . . . . 515Chapter 24: Analyzing Data with the Analysis ToolPak . . . . . . . . . . . . . . . 531 16. 01 539671 FM.qxd 8/28/03 9:59 AM Page xivPart V: Using Advanced Excel Features . . . . . . . . . . . . . . . . . 543Chapter 25: Using Custom Number Formats . . . . . . . . . . .. . . . . . . . . . 545Chapter 26: Customizing Toolbars and Menus . . . . . . . . . . . . . . . . . . . . 563Chapter 27: Using Conditional Formatting and Data Validation . . . . . . . . . . 575Chapter 28: Creating and Using Worksheet Outlines . . . . . .. . . . . . . . . . 591Chapter 29: Linking and Consolidating Worksheets . . . . . . . . . . . . . . . . . 599Chapter 30: Excel and the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . 613Chapter 31: Sharing Data with Other Applications . . . . . . . . . . . . . . . . . 623Chapter 32: Using Excel in a Workgroup . . . . . . . . . . . . . . . . . . . . . . . 639Chapter 33: Making Your Worksheets Error-Free . . . . . . . .. . . . . . . . . . 651Part VI: Programming Excel with VBA . . . . . . . . . . . . . . . . . . 677Chapter 34: Introducing Visual Basic for Applications. . . . . . . . . . . . . . . 679Chapter 35: Creating Custom Worksheet Functions . .. . . . . . . . . . . . . . . 703Chapter 36: Creating UserForms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715Chapter 37: Using UserForm Controls in a Worksheet . . . . . . . . . . . . . . . 733Chapter 38: Working with Excel Events . . . . . . . . .. . . . . . . . . . . . . . . 745Chapter 39: VBA Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757Chapter 40: Creating Custom Excel Add-Ins . . . . . .. . . . . . . . . . . . . . . 773Part VII: Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785Appendix A: Worksheet Function Reference . . . . . . . . . . . . . . . . . . . . . 787Appendix B: Whats on the CD-ROM . . . . . . . . . . . . . . . . . . . . . . . . . 803Appendix C: Just for Fun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 815Appendix D: Additional Excel Resources . . . . . . . . . . . . . . . . . . . . . . . 837Appendix E: Excel Shortcut Keys . . . . . .. . . . . . . . . . . . . . . . . . . . . 845Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853End-User License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 899 17. 01 539671 FM.qxd 8/28/03 9:59 AM Page xv ContentsPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii Part I: Getting Started with Excel1Chapter 1: Introducing Excel . . . . . . . . . . . . . . . . . . . . . . . . . 3 What Is It Good For? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Understanding Workbooks and Worksheets . . . . . . . . . . . . . . . . . . . 4 Moving Around a Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Navigating with your keyboard . . . . . . . . . . . . . . . . . . . . . . . 7Navigating with your mouse . . . . . . . . . . . . . . . . . . . . . . . . . 8 Using the Excel Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . 9Using menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Using shortcut menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Using shortcut keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Using toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Working with Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Understanding dialog box controls . . . . . . . . . . . . . . . . . . . . 14Navigating dialog boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Using tabbed dialog boxes . . . . . . . . . . . . . . . . . . . . . . . . . 16 Creating Your First Excel Worksheet . . . . . . . . . . . . . . . . . . . . . . . 17Getting started on your worksheet . . . . . . . . . . . . . . . . . . . . 18Filling in the month names . . . . . . . . . . . . . . . . . . . . . . . . . 18Entering the sales data . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Summing the values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Making your worksheet look a bit fancier . . . . . . . . . . . . . . . . 20Creating a chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Printing your worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . 22Saving your workbook . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Chapter 2: Entering and Editing Worksheet Data . . . . . . . . . . . . 25 Understanding the Types of Data You Can Use . . . . . . . . . . . . . . . . . 25Understanding numerical values . . . . . . . . . . . . . . . . . . . . . 26Understanding text entries . . . . . . . . . . . . . . . . . . . . . . . . . 26Understanding formulas . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Entering Text and Values into Your Worksheets . . . . . . . . . . . . . . . . 27 Entering Dates and Times into Your Worksheets . . . . . . . . . . . . . . . . 28Entering date values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Entering time values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 18. 01 539671 FM.qxd 8/28/03 9:59 AM Page xvixvi Contents Modifying Cell Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Erasing the contents of a cell . . . . . . . . . . . . . . . . . . . . . . . 30Replacing the contents of a cell . . . . . . . . . . . . . . . . . . . . . . 30Editing the contents of a cell . . . . . . . . . . . . . . . . . . . . . . . . 31Learning some handy data-entry techniques. . . . . . . . . . . . . . 32 Applying Number Formatting . . . . . . . . . . . . .. . . . . . . . . . . . . . 37Improving readability by formatting numbers. . . . . . . . . . . . . . 37Adding your own custom number formats . .. . . . . . . . . . . . . . 42Chapter 3: Essential Worksheet Operations . . . . . . . . . . . . . . . 43 Learning the Fundamentals of Excel Worksheets . . . . . . . . . . . . . . . 43Working with Excels windows . . . . . . . . . . . . . . . . . . . . . . . 43Making a worksheet the active sheet . . . .. . . . . . . . . . . . . . . 46Adding a new worksheet to your workbook. . . . . . . . . . . . . . . 47Deleting a worksheet you no longer need .. . . . . . . . . . . . . . . 48Changing the name of a worksheet . . . . . . . . . . . . . . . . . . . . 48Changing a sheet tabs color . . . . . . . . . . . . . . . . . . . . . . . . 49Rearranging your worksheets . . . . . . . .. . . . . . . . . . . . . . . 49Hiding and unhiding a worksheet . . . . . .. . . . . . . . . . . . . . . 51 Controlling the Worksheet View . . . . . . . . . .. . . . . . . . . . . . . . . 52Viewing a worksheet in multiple windows .. . . . . . . . . . . . . . . 52Comparing sheets side by side . . . . . . .. . . . . . . . . . . . . . . 53Splitting the worksheet window into panes. . . . . . . . . . . . . . . 54Keeping the titles in view by freezing panes . . . . . . . . . . . . . . . 54Zooming in or out for a better view . . . . .. . . . . . . . . . . . . . . 55Saving your view settings . . . . . . . . . . .. . . . . . . . . . . . . . . 57Monitoring cells with a Watch Window . . . . . . . . . . . . . . . . . . 58 Working with Rows and Columns . . . . . . . . . . . . . . . . . . . . . . . . 58Inserting rows and columns . . . . . . . . . . . . . . . . . . . . . . . . 59Deleting rows and columns . . . . . . . . . .. . . . . . . . . . . . . . . 60Hiding rows and columns . . . . . . . . . . .. . . . . . . . . . . . . . . 60Changing column widths and row heights . . . . . . . . . . . . . . . . 61Chapter 4: Working with Cells and Ranges . . . . . . . . . . . . . . . . 63 Understanding Cells and Ranges . . . . . . .. . . . . . . . . . . . . . . . . . 63Selecting ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Selecting complete rows and columns. . . . . . . . . . . . . . . . . . 65Selecting noncontiguous ranges . . . . . . . . . . . . . . . . . . . . . . 65Selecting multisheet ranges . . . . . .. . . . . . . . . . . . . . . . . . 66Selecting special types of cells . . . . . . . . . . . . . . . . . . . . . . . 68 Copying or Moving Ranges . . . . . . . . . .. . . . . . . . . . . . . . . . . . 71Copying by using toolbar buttons . . . . . . . . . . . . . . . . . . . . . 72Copying by using menu commands . . . . . . . . . . . . . . . . . . . . 73Copying by using shortcut keys . . . . . . . . . . . . . . . . . . . . . . 73Copying by using drag-and-drop . . . . . . . . . . . . . . . . . . . . . . 73Copying to adjacent cells . . . . . . . .. . . . . . . . . . . . . . . . . . 74Copying a range to other sheets . . . .. . . . . . . . . . . . . . . . . . 75Using the Office Clipboard to paste . .. . . . . . . . . . . . . . . . . . 76Pasting in special ways . . . . . . . . .. . . . . . . . . . . . . . . . . . 77 19. 01 539671 FM.qxd 8/28/03 9:59 AM Page xviiContentsxvii Using Names to Work with Ranges . . . . . . . .. . . . . . . . . . . . . .. . 79Creating range names in your workbooks. . . . . . . . . . . . . .. . 80Creating a table of range names . . . . . . . . . . . . . . . . . . . .. . 82Modifying existing range names . . . . . .. . . . . . . . . . . . . .. . 82 Adding Comments to Cells . . . . . . . . . . . . . . . . . . . . . . . . . .. . 83Chapter 5: Worksheet Formatting . . . . . . . . . . . . . . . . . . . . . 85 Getting to Know the Formatting Tools . . . . . . . . . . . . . . . . . . . . . . 85 Using the Formatting toolbar . . . . . . . . . . . . . . . . . . . . . . . 86 Using the Format Cells dialog box . . . . . . . . . . . . . . . . . . . . . 86 Using Formatting in Your Worksheets . . . . . . . . . . . . . . . . . . . . . . 87 Using different fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Changing text alignment . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Using colors and shading . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Adding borders and lines . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Adding a background image to a worksheet . . . . . . . . . . . . . . . 96 Using AutoFormat for quick and easy worksheet formatting . . . . . 97 Using Named Styles for Easier Formatting . . . . . . . . . . . . . . . . . . . 98 Applying styles to your worksheets . . . . . . . . . . . . . . . . . . . 100 Creating new styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Modifying a style to meet your needs . . . . . . . . . . . . . . . . . . 102 Merging styles from other workbooks . . . . . . . . . . . . . . . . . . 102 Controlling styles with templates . . . . . . . . . . . . . . . . . . . . 103Chapter 6: Understanding Files and Templates . . . . . . . . . . . . 105 Understanding Excel Files . . . . . . . . .. . . . . . . . . . . . . . . . .. . 105 Creating a new workbook . . . . . .. . . . . . . . . . . . . . . . .. . 105 Opening an existing workbook . . . . . . . . . . . . . . . . . . . .. . 107 Saving and closing your workbooks. . . . . . . . . . . . . . . . .. . 110 Using AutoRecover . . . . . . . . . .. . . . . . . . . . . . . . . . .. . 111 Safeguarding your work . . . . . . . . . . . . . . . . . . . . . . . .. . 114 Understanding Excel Templates . . . . .. . . . . . . . . . . . . . . . .. . 115 Working with the default templates . . . . . . . . . . . . . . . . .. . 116 Creating custom templates . . . . .. . . . . . . . . . . . . . . . .. . 118Chapter 7: Printing Your Work . . . . . . . . . . . . . . . . . . . . . . . 121 Printing with One Click . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . 121 Adjusting Your Print Settings for Better Results . . . . . . . . . . . . .. . 122 Adjusting the settings in the Print dialog box . . . . . . . . . . .. . 122 Adjusting the Page Setup settings . . . . . . . . .. . . . . . . . .. . 125 Controlling where pages break in your printouts. . . . . . . . .. . 132 Preventing certain cells from being printed . . .. . . . . . . . .. . 132 Using Print Preview . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . 133 Viewing the print preview . . . . . . . . . . . . . .. . . . . . . . .. . 133 Changing print settings while previewing . . . . . . . . . . . . . .. . 134 Using Page Break Preview mode . . . . . . . . . .. . . . . . . . .. . 135 Creating custom views of your worksheet . . . .. . . . . . . . .. . 137 20. 01 539671 FM.qxd 8/28/03 9:59 AM Page xviii xviiiContents Part II: Working with Formulas and Functions 139Chapter 8: Introducing Formulas and Functions . . . . . . . . . . . . 141 Understanding Formula Basics . . . . . . . . . . . . . . . . . . . . . . . . . 141 Using operators in formulas . . . . . . . . . . . .. . . . . . . . . . . 142 Understanding operator precedence in formulas. . . . . . . . . . . 143 Using functions in your formulas . . . . . . . . . . . . . . . . . . . . . 145 Entering Formulas into Your Worksheets . . . . . . . . . . . . . . . . . . . 147 Entering formulas manually . . . . . . . . . . . . . . . . . . . . . . . . 148 Entering formulas by pointing . . . . . . . . . . .. . . . . . . . . . . 148 Pasting range names into formulas . . . . . . . .. . . . . . . . . . . 148 Inserting functions into formulas . . . . . . . . .. . . . . . . . . . . 149 Function entry tips . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 150 Editing Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Using Cell References in Formulas . . . . . . . . . . . .. . . . . . . . . . . 152 Using relative, absolute, and mixed references . . . . . . . . . . . . . 152 Changing the types of your references . . . . . .. . . . . . . . . . . 154 Referencing cells outside the worksheet . . . . .. . . . . . . . . . . 155 Correcting Common Formula Errors . . . . . . . . . . . . . . . . . . . . . . 156 Handling circular references . . . . . . . . . . . . . . . . . . . . . . . 157 Changing when formulas are calculated . . . . . .. . . . . . . . . . . 159 Using Advanced Naming Techniques . . . . . . . . . . . . . . . . . . . . . . 160 Using names for constants . . . . . . . . . . . . .. . . . . . . . . . . 161 Using names for formulas . . . . . . . . . . . . . . . . . . . . . . . . . 161 Using range intersections . . . . . . . . . . . . . .. . . . . . . . . . . 162 Applying names to existing references . . . . . .. . . . . . . . . . . 164 Tips for Working with Formulas . . . . . . . . . . . . . . . . . . . . . . . . . 165 Dont hard-code values . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Using the formula bar as a calculator . . . . . . .. . . . . . . . . . . 165 Making an exact copy of a formula . . . . . . . . .. . . . . . . . . . . 166 Converting formulas to values . . . . . . . . . . .. . . . . . . . . . . 166Chapter 9: Creating Formulas That Manipulate Text . . . . . . . . . 169 A Few Words about Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 How many characters in a cell? . . . . . . . . . . . . . . . . . . . . . 169 Numbers as text . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 170 Text Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Determining whether a cell contains text . . . . . . . . . . . . . . . . 171 Working with character codes . . . . . . . . . . . . . . . . . . . . . . 171 Determining whether two strings are identical. . . . . . . . . . . . . 173 Joining two or more cells . . . . . . . . . . . .. . . . . . . . . . . . . 173 Displaying formatted values as text . . . . . .. . . . . . . . . . . . . 175 Displaying formatted currency values as text . . . . . . . . . . . . . 176 Repeating a character or string . . . . . . . .. . . . . . . . . . . . . 176 Creating a text histogram . . . . . . . . . . . .. . . . . . . . . . . . . 177 21. 01 539671 FM.qxd 8/28/03 9:59 AM Page xixContentsxix Padding a number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Removing excess spaces and nonprinting characters .. . . . . . . . 179 Counting characters in a string . . . . . . . . . . . . . .. . . . . . . . 179 Changing the case of text . . . . . . . . . . . . . . . . .. . . . . . . . 179 Extracting characters from a string . . . . . . . . . . .. . . . . . . . 180 Replacing text with other text . . . . . . . . . . . . . . . . . . . . . . 181 Finding and searching within a string . . . . . . . . . .. . . . . . . . 182 Searching and replacing within a string . . . . . . . . .. . . . . . . . 182 Advanced Text Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Counting specific characters in a cell . . . . . . . . . . . . . . . . . . 183 Counting the occurrences of a substring in a cell . . .. . . . . . . . 183 Extracting a filename from a path specification . . . .. . . . . . . . 184 Extracting the first word of a string . . . . . . . . . . .. . . . . . . . 184 Extracting the last word of a string . . . . . . . . . . . . . . . . . . . 184 Extracting all but the first word of a string . . . . . . .. . . . . . . . 185 Extracting first names, middle names, and last names . . . . . . . . 185 Removing titles from names . . . . . . . . . . . . . . . . . . . . . . . 187 Counting the number of words in a cell . . . . . . . . . . . . . . . . . 187Chapter 10: Working with Dates and Times . . . . . . . . . . . . . . . 189 How Excel Handles Dates and Times . . . . . . . . . . . . . . .. . . . . . . 189Understanding date serial numbers . . . . . . . . . . . . . . . . . . . 189Entering dates . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 190Understanding time serial numbers . . . . . . . . . . . . . . . . . . . 192Entering times . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 194Formatting dates and times . . . . . . . . . . . . . . . . .. . . . . . . 195Problems with dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 Date-Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Displaying the current date . . . . . . . . . . . . . . . . . . . . . . . . 199Displaying any date . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199Generating a series of dates . . . . . . . . . . . . . . . .. . . . . . . 200Converting a non-date string to a date . . . . . . . . . .. . . . . . . 201Calculating the number of days between two dates . . .. . . . . . . 202Calculating the number of workdays between two dates. . . . . . . 203Offsetting a date using only workdays . . . . . . . . . . . . . . . . . . 204Calculating the number of years between two dates . . . . . . . . . 204Calculating a persons age . . . . . . . . . . . . . . . . . .. . . . . . . 205Determining the day of the year . . . . . . . . . . . . . . . . . . . . . 206Determining the day of the week . . . . . . . . . . . . . . . . . . . . . 206Determining the date of the most recent Sunday . . . .. . . . . . . 207Determining the first day of the week after a date . . . .. . . . . . . 207Determining the nth occurrence of a day of the week in a month . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 207Calculating dates of holidays . . . . . . . . . . . . . . . . . . . . . . . 208Determining the last day of a month . . . . . . . . . . . . . . . . . . . 210Determining whether a year is a leap year . . . . . . . . . . . . . . . 211Determining a dates quarter . . . . . . . . . . . . . . . .. . . . . . . 211 22. 01 539671 FM.qxd 8/28/03 9:59 AM Page xx xx Contents Time-Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Displaying the current time . . . . . . . . . . . . . . . . . . . . . . . . 212Displaying any time . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Calculating the difference between two times . . . . . . .. . . . . . 213Summing times that exceed 24 hours . . . . . . . . . . . .. . . . . . 214Converting from military time . . . . . . . . . . . . . . . . . . . . . . 217Converting decimal hours, minutes, or seconds to a time . . . . . . 217Adding hours, minutes, or seconds to a time . . . . . . . . . . . . . . 218Rounding time values . . . . . . . . . . . . . . . . . . . . .. . . . . . 219Working with non-time-of-day values . . . . . . . . . . . . . . . . . . 219Chapter 11: Creating Formulas That Count and Sum . . . . . . . . . 221 Counting and Summing Worksheet Cells . . . . . . . . . . . . . . . . . . . . 221 Basic Counting Formulas . . . . . . . . . . . . . . .. . . . . . . . . . . . . 223Counting the total number of cells . . . . . . .. . . . . . . . . . . . . 224Counting blank cells . . . . . . . . . . . . . . .. . . . . . . . . . . . . 225Counting nonblank cells . . . . . . . . . . . . . . . . . . . . . . . . . . 225Counting numeric cells . . . . . . . . . . . . .. . . . . . . . . . . . . 226Counting nontext cells . . . . . . . . . . . . . .. . . . . . . . . . . . . 226Counting text cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226Counting logical values . . . . . . . . . . . . . . . . . . . . . . . . . . 226Counting error values in a range . . . . . . . .. . . . . . . . . . . . . 226 Advanced Counting Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . 227Counting cells by using the COUNTIF function. . . . . . . . . . . . . 227Counting cells by using multiple criteria . . . . . . . . . . . . . . . . 228Counting the most frequently occurring entry. . . . . . . . . . . . . 231Counting the occurrences of specific text . . . . . . . . . . . . . . . 232Counting the number of unique values . . . .. . . . . . . . . . . . . 234Creating a frequency distribution . . . . . . . . . . . . . . . . . . . . 235 Summing Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239Summing all cells in a range . . . . . . . . . .. . . . . . . . . . . . . 240Computing a cumulative sum . . . . . . . . . .. . . . . . . . . . . . . 241Summing the top n values . . . . . . . . . . .. . . . . . . . . . . . . 242 Conditional Sums Using a Single Criterion . . . . . .. . . . . . . . . . . . . 242Summing only negative values . . . . . . . . .. . . . . . . . . . . . . 243Summing values based on a different range . . . . . . . . . . . . . . 244Summing values based on a text comparison . . . . . . . . . . . . . 245Summing values based on a date comparison . . . . . . . . . . . . . 245 Conditional Sums Using Multiple Criteria . . . . . . . . . . . . . . . . . . . 245Using And criteria . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 246Using Or criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247Using And and Or criteria . . . . . . . . . . . . . . . . . . . . . . . . . 247Chapter 12: Creating Formulas That Look Up Values . . . . . . . . . 249 Introducing Lookup Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Functions Relevant to Lookups . . . . . . . . . . . . . . . . . . . . . . . . . 250 23. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxiContentsxxi Basic Lookup Formulas . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 252The VLOOKUP function . . . . . . . . . . . . . . . . . .. . . . . . . . 252The HLOOKUP function . . . . . . . . . . . . . . . . . .. . . . . . . . 253The LOOKUP function . . . . . . . . . . . . . . . . . . . . . . . . . . . 254Combining the MATCH and INDEX functions . . . . . . . . . . . . . . 255 Specialized Lookup Formulas . . . . . . . . . . . . . . . . . .. . . . . . . . 257Looking up an exact value . . . . . . . . . . . . . . . . . . . . . . . . . 257Looking up a value to the left . . . . . . . . . . . . . . .. . . . . . . . 258Performing a case-sensitive lookup . . . . . . . . . . .. . . . . . . . 260Choosing among multiple lookup tables . . . . . . . . . . . . . . . . 260Determining letter grades for test scores . . . . . . . . . . . . . . . . 261Calculating a grade-point average . . . . . . . . . . . . . . . . . . . . 262Performing a two-way lookup . . . . . . . . . . . . . . . . . . . . . . . 263Performing a two-column lookup . . . . . . . . . . . .. . . . . . . . 265Determining the cell address of a value within a range. . . . . . . . 266Looking up a value by using the closest match . . . . . . . . . . . . 267Chapter 13: Creating Formulas for Financial Applications . . . . . . 269 The Time Value of Money . . . . . . . . . . . . . . . . . . . .. . . . . . . . 269 Loan Calculations . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 270Worksheet functions for calculating loan information .. . . . . . . . 271A loan calculation example . . . . . . . . . . . . . . . .. . . . . . . . 274Credit card payments . . . . . . . . . . . . . . . . . . .. . . . . . . . 275Creating a loan amortization schedule . . . . . . . . . . . . . . . . . 277Summarizing loan options by using a data table . . . .. . . . . . . . 279Calculating a loan with irregular payments . . . . . . .. . . . . . . . 282 Investment Calculations . . . . . . . . . . . . . . . . . . . . .. . . . . . . . 283Future value of a single deposit . . . . . . . . . . . . .. . . . . . . . 284Future value of a series of deposits . . . . . . . . . . .. . . . . . . . 288 Depreciation Calculations . . . . . . . . . . . . . . . . . . . .. . . . . . . . 290Chapter 14: Introducing Array Formulas . . . . . . . . . . . . . . . . . 295 Understanding Array Formulas . . . . . . . . . . . . . . . . . . . . . . . . . 295A multicell array formula . . . . . . . . . . . . . . . . . . . . . . . . . 296A single-cell array formula . . . . . . . . . . . . . . . . . . . . . . . . 297Creating an array constant . . . . . .. . . . . . . . . . . . . . . . . . 298Array constant elements . . . . . . . . . . . . . . . . . . . . . . . . . 299 Understanding the Dimensions of an Array . . . . . . . . . . . . . . . . . . 299One-dimensional horizontal arrays . . . . . . . . . . . . . . . . . . . 300One-dimensional vertical arrays . . . . . . . . . . . . . . . . . . . . . 300Two-dimensional arrays . . . . . . . .. . . . . . . . . . . . . . . . . . 301 Naming Array Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 Working with Array Formulas . . . . . . . .. . . . . . . . . . . . . . . . . . 303Entering an array formula . . . . . . . . . . . . . . . . . . . . . . . . . 303Selecting an array formula range . . .. . . . . . . . . . . . . . . . . . 304 24. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxiixxiiContentsEditing an array formula . . . . . . . . . . . . . . . .. . . . . . . . . . 304Expanding or contracting a multicell array formula. . . . . . . . . . 305 Using Multicell Array Formulas . . . . . . . . . . . . . . . . . . . . . . . . . 306Creating an array from values in a range . . . . . .. . . . . . . . . . 306Creating an array constant from values in a range . . . . . . . . . . . 306Performing operations on an array . . . . . . . . . . . . . . . . . . . 307Using functions with an array . . . . . . . . . . . . . . . . . . . . . . 308Transposing an array . . . . . . . . . . . . . . . . .. . . . . . . . . . 308Generating an array of consecutive integers . . . . . . . . . . . . . . 309 Using Single-Cell Array Formulas . . . . . . . . . . . . . . . . . . . . . . . . 311Counting characters in a range . . . . . . . . . . . .. . . . . . . . . . 311Summing the three smallest values in a range . . .. . . . . . . . . . 312Counting text cells in a range . . . . . . . . . . . . .. . . . . . . . . . 313Eliminating intermediate formulas . . . . . . . . . . . . . . . . . . . . 314Using an array in lieu of a range reference . . . . . . . . . . . . . . . 315Chapter 15: Performing Magic with Array Formulas . . . . . . . . . . 317 Working with Single-Cell Array Formulas . . . . . . . . .. . . . . . . . . . 317Summing a range that contains errors . . . . . . . .. . . . . . . . . . 318Counting the number of error values in a range . .. . . . . . . . . . 318Summing based on a condition . . . . . . . . . . . .. . . . . . . . . . 319Summing the n largest values in a range . . . . . . . . . . . . . . . . 320Computing an average that excludes zeros . . . . .. . . . . . . . . . 321Determining whether a particular value appears in a range . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Counting the number of differences in two ranges. . . . . . . . . . 323Returning the location of the maximum value in a range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323Finding the row of a values nth occurrence in a range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324Returning the longest text in a range . . . . . . . . . . . . . . . . . . 324Determining whether a range contains valid values . . . . . . . . . . 324Summing the digits of an integer . . . . . . . . . . .. . . . . . . . . . 325Summing rounded values . . . . . . . . . . . . . . .. . . . . . . . . . 326Summing every nth value in a range . . . . . . . . .. . . . . . . . . . 327Removing non-numeric characters from a string . . . . . . . . . . . 329Determining the closest value in a range . . . . . .. . . . . . . . . . 329Returning the last value in a column . . . . . . . . .. . . . . . . . . . 330Returning the last value in a row . . . . . . . . . . . . . . . . . . . . . 331Ranking data with an array formula . . . . . . . . .. . . . . . . . . . 331 Working with Multicell Array Formulas . . . . . . . . . .. . . . . . . . . . 332Returning only positive values from a range . . . . . . . . . . . . . . 332Returning nonblank cells from a range . . . . . . . . . . . . . . . . . 333Returning a list of unique items in a range . . . . . . . . . . . . . . . 334Displaying a calendar in a range . . . . . . . . . . .. . . . . . . . . . 334 25. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxiiiContentsxxiii Part III: Creating Charts and Graphics 337Chapter 16: Getting Started Making Charts . . . . . . . . . . . . . . . 339 What Is a Chart? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 How Excel Handles Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 Embedded charts . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 341 Chart sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 Parts of a Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 Creating Charts . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 344 Creating a chart with one keystroke . . . . .. . . . . . . . . . . . . . 344 Creating a chart with a mouse click . . . . .. . . . . . . . . . . . . . 345 Using the Chart Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Hands On: Creating a Chart with the Chart Wizard . . . . . . . . . . . . . . 348 Selecting the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 Chart Wizard Step 1 of 4 . . . . . . . . . . . . . . . . . . . . . . . . 349 Chart Wizard Step 2 of 4 . . . . . . . . . . . . . . . . . . . . . . . . 350 Chart Wizard Step 3 of 4 . . . . . . . . . . . . . . . . . . . . . . . . 353 Chart Wizard Step 4 of 4 . . . . . . . . . . . . . . . . . . . . . . . . 354 Basic Chart Modifications . . . . . . . . . . . . . .. . . . . . . . . . . . . . 355 Moving and resizing a chart . . . . . . . . .. . . . . . . . . . . . . . 356 Changing the chart type . . . . . . . . . . . .. . . . . . . . . . . . . . 356 Copying a chart . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 356 Deleting a chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Moving and deleting chart elements . . . . . . . . . . . . . . . . . . . 357 Other modifications . . . . . . . . . . . . . .. . . . . . . . . . . . . . 357 Printing Charts . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 357 Understanding Chart Types . . . . . . . . . . . . .. . . . . . . . . . . . . . 359 Choosing a chart type . . . . . . . . . . . . .. . . . . . . . . . . . . . 359 Standard chart types . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 Column charts . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 361 Bar charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 Line charts . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 363 Pie charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 XY (scatter) charts . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 366 Area charts . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 366 Doughnut charts . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 367 Radar charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Surface charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 Bubble charts . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 369 Stock charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 Cylinder, cone, and pyramid charts . . . . . . . . . . . . . . . . . . . 371 26. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxiv xxiv ContentsChapter 17: Learning Advanced Charting . . . . . . . . . . . . . . . . 373 Understanding Chart Customization . . . . . . . . . . . . .. . . . . . . . . 373 Changing Basic Chart Elements . . . . . . . . . . . . . . . .. . . . . . . . . 374Selecting chart elements . . . . . . . . . . . . . . . .. . . . . . . . . 374Modifying properties by using the Format dialog box . . . . . . . . . 376Modifying the Chart Area . . . . . . . . . . . . . . . .. . . . . . . . . 377Modifying the Plot Area . . . . . . . . . . . . . . . . . . . . . . . . . . 377Working with chart titles . . . . . . . . . . . . . . . . . . . . . . . . . 378Working with the legend . . . . . . . . . . . . . . . . . . . . . . . . . . 379Changing the chart gridlines . . . . . . . . . . . . . .. . . . . . . . . 381Modifying the axes . . . . . . . . . . . . . . . . . . . .. . . . . . . . . 382 Working with Data Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385Deleting a data series . . . . . . . . . . . . . . . . . .. . . . . . . . . 386Adding a new data series to a chart . . . . . . . . . . . . . . . . . . . 386Changing data used by a series . . . . . . . . . . . . .. . . . . . . . . 387Displaying data labels in a chart . . . . . . . . . . . . . . . . . . . . . 389Handling missing data . . . . . . . . . . . . . . . . . . . . . . . . . . . 390Controlling a data series by hiding data . . . . . . . .. . . . . . . . . 390Adding error bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391Adding a trend line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392Modifying 3-D charts . . . . . . . . . . . . . . . . . . .. . . . . . . . . 392Formatting a surface chart . . . . . . . . . . . . . . .. . . . . . . . . 393Creating combination charts . . . . . . . . . . . . . . . . . . . . . . . 394Using secondary axes . . . . . . . . . . . . . . . . . .. . . . . . . . . 395Displaying a data table . . . . . . . . . . . . . . . . . . . . . . . . . . 395 Creating Custom Chart Types . . . . . . . . . . . . . . . . .. . . . . . . . . 396About custom chart types . . . . . . . . . . . . . . .. . . . . . . . . 396Creating your own custom chart types . . . . . . . .. . . . . . . . . 396 Learning Some Chart-Making Tricks . . . . . . . . . . . . .. . . . . . . . . 398Creating picture charts . . . . . . . . . . . . . . . . . . . . . . . . . . 398Creating a thermometer chart . . . . . . . . . . . . .. . . . . . . . . 399Creating a gauge chart . . . . . . . . . . . . . . . . . .. . . . . . . . . 400Creating a comparative histogram . . . . . . . . . . .. . . . . . . . . 401Creating a Gantt chart . . . . . . . . . . . . . . . . . .. . . . . . . . . 402Creating a chart that updates automatically . . . . . . . . . . . . . . 403Plotting mathematical functions with one variable . . . . . . . . . . 404Plotting mathematical functions with two variables .. . . . . . . . . 405 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 406Questions about chart settings . . . . . . . . . . . . .. . . . . . . . . 406Chart formatting questions . . . . . . . . . . . . . . .. . . . . . . . . 408Chart series questions . . . . . . . . . . . . . . . . . .. . . . . . . . . 412Chart type questions . . . . . . . . . . . . . . . . . .. . . . . . . . . 414Miscellaneous chart questions . . . . . . . . . . . . . . . . . . . . . . 415Chapter 18: Enhancing Your Work with Pictures and Drawings . . . 419 Using AutoShapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419The AutoShapes toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . 419Inserting AutoShapes . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 27. 01 539671 FM.qxd 8/28/03 9:59 AMPage xxvContentsxxvAdding text to an AutoShape . . . . . . . . . . . . . . . . . . . . . . . 422Formatting AutoShape objects . . . . . . . . . . .. . . . . . . . . . . 423Selecting multiple objects . . . . . . . . . . . . . .. . . . . . . . . . . 423Moving objects . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 423Copying objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424Rotating AutoShapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424Modifying AutoShapes . . . . . . . . . . . . . . . .. . . . . . . . . . . 424Changing the stack order of objects . . . . . . . . . . . . . . . . . . . 424Grouping objects . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 424 Using the Drawing Toolbar . . . . . . . . . . . . . . . .. . . . . . . . . . . 425Aligning objects . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 425Spacing objects evenly . . . . . . . . . . . . . . .. . . . . . . . . . . 426Changing an AutoShape to a different AutoShape. . . . . . . . . . . 426Adding shadows and 3-D effects . . . . . . . . . .. . . . . . . . . . . 426Changing the AutoShape defaults . . . . . . . . . . . . . . . . . . . . 427Printing objects . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 427 Working with Other Graphic Types . . . . . . . . . . . . . . . . . . . . . . . 428About graphics files . . . . . . . . . . . . . . . . .. . . . . . . . . . . 428Using the Microsoft Clip Organizer . . . . . . . .. . . . . . . . . . . 428Inserting graphics files . . . . . . . . . . . . . . .. . . . . . . . . . . 430Copying graphics by using the Clipboard . . . . . . . . . . . . . . . . 430Importing from a digital camera or scanner . . .. . . . . . . . . . . 430Displaying a worksheet background image . . . . . . . . . . . . . . . 431Modifying pictures . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 431 Using the Office Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432Creating diagrams and org charts . . . . . . . . .. . . . . . . . . . . 432Creating WordArt . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 434 Part IV: Analyzing Data with Excel 435Chapter 19: Working with Lists . . . . . . . . . . . . . . . . . . . . . . 437 What Is a List? . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 437 What Can You Do with a List? . . . . . . . . . . . . . . . . . . . . . . . . . . 438 Designing a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 Entering Data into a List . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 439Entering data with the Data Form dialog box . . . . . . . . . . . . . . 441Other uses for the Data Form dialog box . . . . . . . . . . . . . . . . 441 Filtering a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442Using autofiltering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442Using advanced filtering . . . . . . . . . . . .. . . . . . . . . . . . . . 446 Using Database Functions with Lists . . . . . . . .. . . . . . . . . . . . . . 452 Sorting a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Simple sorting . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 454More-complex sorting . . . . . . . . . . . . .. . . . . . . . . . . . . . 455Using a custom sort order . . . . . . . . . . . . . . . . . . . . . . . . 456Sorting nonlists . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 457 Creating Subtotals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 28. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxvi xxvi Contents Working with a Designated List . . . . . . . . . . . . .. . . . . . . . . . . . 460Creating a designated list . . . . . . . . . . . . . . . . . . . . . . . . . 460Adding rows or columns to a designated list .. . . . . . . . . . . . 461Adding summary formulas to a designated list . . . . . . . . . . . . 462Advantage in using a designated list . . . . . . . . . . . . . . . . . . . 462Chapter 20: Using External Database Files . . . . . . . . . . . . . . . 463 Understanding External Database Files . . . . . . . . . . . . . . . . . . . . 463 Retrieving Data with Query: An Example . . . . . . . . . . . .. . . . . . . 465 The database file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 The task . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 466 Using Query to get the data . . . . . . . . . . . . . . . . . . . . . . . . 466 Working with Data Returned by Query . . . . . . . . . . . . . . . . . . . . . 472 Adjusting the external data range properties . . . . . . .. . . . . . . 472 Refreshing a query . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 473 Deleting a query . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 474 Changing your query . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 Using Query without the Wizard . . . . . . . . . . . . . . . . .. . . . . . . 474 Creating a query manually . . . . . . . . . . . . . . . . . . . . . . . . 475 Using multiple database tables . . . . . . . . . . . . . . .. . . . . . . 476 Adding and editing records in external database tables. . . . . . . 477 Formatting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 Learning more about Query . . . . . . . . . . . . . . . . . . . . . . . 477Chapter 21: Analyzing Data with Pivot Tables . . . . . . . . . . . . . 479 About Pivot Tables . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 479A pivot table example . . . . . . . . . . . . .. . . . . . . . . . . . . . 480Data appropriate for a pivot table . . . . . . . . . . . . . . . . . . . . 482 Creating a Pivot Table . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 484Step1: Specifying the data location . . . . .. . . . . . . . . . . . . . 484Step 2: Specifying the data . . . . . . . . . .. . . . . . . . . . . . . . 485Step 3: Completing the pivot table . . . . . . . . . . . . . . . . . . . . 486 Grouping Pivot Table Items . . . . . . . . . . . . .. . . . . . . . . . . . . . 492 Creating a Calculated Field or Calculated Item . .. . . . . . . . . . . . . . 495Creating a calculated field in a pivot table . . . . . . . . . . . . . . . 496Inserting a calculated item into a pivot table . . . . . . . . . . . . . . 497Chapter 22: Performing Spreadsheet What-If Analysis . . . . . . . . 501 A What-If Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 Types of What-If Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 Manual What-If Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 Creating Data Tables . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 503Creating a one-input data table. . . . . . . . . . . . . . . . . . . . . . 504Creating a two-input data table. . . . . . . . . . . . . . . . . . . . . . 506 29. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxvii Contentsxxvii Using Scenario Manager . . . . . .. . . . . . . . . . . . . . . . . . . . . . . 509Defining scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509Displaying scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512Modifying scenarios . . . . .. . . . . . . . . . . . . . . . . . . . . . . 513Merging scenarios . . . . . .. . . . . . . . . . . . . . . . . . . . . . . 513Generating a scenario report . . . . . . . . . . . . . . . . . . . . . . . 513Chapter 23: Analyzing Data Using Goal Seek and Solver . . . . . . . 515 What-If Analysis in Reverse . . . . . . . . . . . . . . . . . . . . . . . . . . 515 Single-Cell Goal Seeking . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 516 A goal-seeking example . . . . . . .. . . . . . . . . . . . . . . . . . . 516 More about goal seeking . . . . . . . . . . . . . . . . . . . . . . . . . 517 Introducing Solver . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 518 Appropriate problems for Solver . . . . . . . . . . . . . . . . . . . . . 518 A simple Solver example . . . . . . . . . . . . . . . . . . . . . . . . . 519 More about Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 Solver Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524 Minimizing shipping costs . . . . . . . . . . . . . . . . . . . . . . . . 524 Allocating resources . . . . . . . . .. . . . . . . . . . . . . . . . . . . 527 Optimizing an investment portfolio. . . . . . . . . . . . . . . . . . . 528Chapter 24: Analyzing Data with the Analysis ToolPak . . . . . . . . 531 The Analysis ToolPak: An Overview . . . . . . . . . . . . . . . . . . . . . . 531 Using the Analysis ToolPak . . . . . . . . . . . . . . .. . . . . . . . . . . . 532Installing the Analysis ToolPak add-in . . . . . . . . . . . . . . . . . . 532Using the Analysis tools . . . . . . . . . . . . . . . . . . . . . . . . . . 533Using the Analysis ToolPak functions . . . . . . . . . . . . . . . . . . 533 The Analysis ToolPak Tools . . . . . . . . . . . . . . .. . . . . . . . . . . . 534The Analysis of Variance tool . . . . . . . . . . .. . . . . . . . . . . . 534The Correlation tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535The Covariance tool . . . . . . . . . . . . . . . .. . . . . . . . . . . . 536The Descriptive Statistics tool . . . . . . . . . .. . . . . . . . . . . . 536The Exponential Smoothing tool . . . . . . . . . . . . . . . . . . . . . 536The F-Test (Two-Sample Test for Variance) tool . . . . . . . . . . . . 537The Fourier Analysis tool . . . . . . . . . . . . .. . . . . . . . . . . . 537The Histogram tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537The Moving Average tool . . . . . . . . . . . . .. . . . . . . . . . . . 538The Random Number Generation tool . . . . . .. . . . . . . . . . . . 538The Rank and Percentile tool . . . . . . . . . . . . . . . . . . . . . . . 540The Regression tool . . . . . . . . . . . . . . . .. . . . . . . . . . . . 540The Sampling tool . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 541The t-Test tool . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 542The z-Test (Two-Sample Test for Means) tool .. . . . . . . . . . . . 542 30. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxviiixxviiiContents Part V: Using Advanced Excel Features543Chapter 25: Using Custom Number Formats . . . . . . . . . . . . . . 545 About Number Formatting . . . . . . . . . . . . . . . . . . .. . . . . . . . . 545Automatic number formatting . . . . . . . . . . . . . . . . . . . . . . 545Formatting numbers by using toolbar buttons . . . . . . . . . . . . . 546Using shortcut keys to format numbers . . . . . . . . . . . . . . . . . 547Using the format cells dialog box to format numbers . . . . . . . . . 547 Creating a Custom Number Format . . . . . . . . . . . . . .. . . . . . . . . 548About custom number formats . . . . . . . . . . . . . . . . . . . . . . 549Parts of a number format string . . . . . . . . . . . . . . . . . . . . . 550Custom number format codes . . . . . . . . . . . . .. . . . . . . . . 551 Custom Number Format Examples . . . . . . . . . . . . . .. . . . . . . . . 553Scaling values . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . 553Displaying leading zeros . . . . . . . . . . . . . . . . .. . . . . . . . . 557Displaying fractions . . . . . . . . . . . . . . . . . . .. . . . . . . . . 557Displaying a negative sign on the right . . . . . . . . . . . . . . . . . 558Formatting dates and times . . . . . . . . . . . . . . .. . . . . . . . . 559Displaying text with numbers . . . . . . . . . . . . . .. . . . . . . . . 559Suppressing certain types of entries . . . . . . . . . .. . . . . . . . . 560Filling a cell with a repeating character . . . . . . . . . . . . . . . . . 561Chapter 26: Customizing Toolbars and Menus . . . . . . . . . . . . . 563 Customizing Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563Types of customizations . . . . . . . . . . . . . . . . . . . . . . . . . 564Shortcut menus . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 565 Moving Toolbars . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 565 Using the Customize Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . 565The Toolbars tab . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 565The Commands tab . . . . . . .. . . . . . . . . . . . . . . . . . . . . 568The Options tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 Adding or Removing Toolbar Buttons . . . . . . . . . . . . . . . . . . . . . 569Moving and copying buttons . .. . . . . . . . . . . . . . . . . . . . . 570Inserting a new button . . . . . .. . . . . . . . . . . . . . . . . . . . . 570 Other Toolbar Button Operations . .. . . . . . . . . . . . . . . . . . . . . 570 Changing a Toolbar Buttons Image . .. . . . . . . . . . . . . . . . . . . . . 572Using a built-in image . . . . . .. . . . . . . . . . . . . . . . . . . . . 572Editing a button image . . . . . .. . . . . . . . . . . . . . . . . . . . . 572Copying another button image .. . . . . . . . . . . . . . . . . . . . . 573Chapter 27: Using Conditional Formatting and Data Validation . . . 575 Conditional Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 Specifying conditional formatting . . . . .. . . . . . . . . . . . . . . 576 Formatting types you can apply . . . . . . . . . . . . . . . . . . . . . 576 Specifying conditions . . . . . . . . . . . .. . . . . . . . . . . . . . . 577 Working with conditional formats . . . . . . . . . . . . . . . . . . . . 579 Conditional formatting formula examples. . . . . . . . . . . . . . . 582 31. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxix Contentsxxix Data Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584Specifying validation criteria . . . . . . . . . . . . . . . . . . . . . . . 585Types of validation criteria you can apply . . . . . . . . . . . . . . . 586Creating a drop-down list . . . . . . . . . . . . . . . . . . . . . .. . . 587Using formulas for data validation rules . . . . . . . . . . . . . . . . 589Using data validation formulas to accept only specific entries . . . 589Chapter 28: Creating and Using Worksheet Outlines . . . . . . . . . 591 Introducing Worksheet Outlines . . . .. . . . . . . . . . . . . . . . . . . . 591 Creating an Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594 Preparing the data . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 594 Creating an outline automatically . . . . . . . . . . . . . . . . . . . . 595 Creating an outline manually . . .. . . . . . . . . . . . . . . . . . . . 596 Working with Outlines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 Displaying levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 Adding data to an outline . . . . . . . . . . . . . . . . . . . . . . . . . 597 Removing an outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 Hiding the outline symbols . . . .. . . . . . . . . . . . . . . . . . . . 598Chapter 29: Linking and Consolidating Worksheets . . . . . . . . . 599 Linking Workbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Why link workbooks? . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Creating external reference formulas . . . . . . . . . . . . . . .. . . 600 Working with external reference formulas . . . . . . . . . . . .. . . 602 Potential problems with external reference formulas . . . . . . . . . 604 Consolidating Worksheets . . . . . . . . . . . . . . . . . . . . . . . . .. . . 605 Consolidating worksheets by using formulas . . . . . . . . . . .. . . 606 Consolidating worksheets by using Paste Special . . . . . . . . . . . 607 Consolidating worksheets by using the Consolidate command . . . 608Chapter 30: Excel and the Internet . . . . . . . . . . . . . . . . . . . . 613 Understanding How Excel Uses HTML . . . . . . . . . . . . . . . . . . . . . 613How does it work? . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 614Adding some complexity . . . . . . . . . . . . . . . . . . . . . . . . . 615What about interactivity? . . . .. . . . . . . . . . . . . . . . . . . . . 616Saving as an XML spreadsheet . . . . . . . . . . . . . . . . . . . . . . 617 Working with Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619Inserting a hyperlink . . . . . . .. . . . . . . . . . . . . . . . . . . . . 619Using hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620 Using Web Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620Chapter 31: Sharing Data with Other Applications . . . . . . . . . . 623 Understanding Data Sharing . . . .. . . . . . . . . . . . . . . . . . . . . . . 623 Pasting and Linking Data . . . . . .. . . . . . . . . . . . . . . . . . . . . . . 624Using the Clipboards . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624Linking data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626Copying Excel data to Word . . . . . . . . . . . . . . . . . . . . . . . . 627 32. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxxxxx Contents Embedding Objects in Documents . . . . . . . . . . . . . . . . . . . . . . . 628Embedding an Excel range in a Word document . . . . . . . . . . . . 629Creating a new Excel object in Word . . . . . . . . . . . . . . . . . . . 630Embedding objects in an Excel worksheet . . . . . . . . . . . . . . . 632 Working with XML Data . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 632What is XML? . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 633Importing XML data by using a map . . . . . . . . . . . . . . . . . . . 634Importing XML data to a list . . . . . . . . . . .. . . . . . . . . . . . 636Exporting XML data from Excel . . . . . . . . . . . . . . . . . . . . . 636Chapter 32: Using Excel in a Workgroup . . . . . . . . . . . . . . . . 639 Using Excel on a Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 Understanding File Reservations . . . . . . . . . . . .. . . . . . . . . . . . 640 Sharing Workbooks . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 641 Understanding shared workbooks . . . . . . . . . . . . . . . . . . . . 642 Designating a workbook as a shared workbook. . . . . . . . . . . . 642 Controlling the advanced sharing settings . . .. . . . . . . . . . . . 643 Mailing and Routing Workbooks . . . . . . . . . . . .. . . . . . . . . . . . 645 E-mailing a worksheet or workbook . . . . . . .. . . . . . . . . . . . 645 Routing a workbook to others . . . . . . . . . . . . . . . . . . . . . . 646 Tracking Workbook Changes . . . . . . . . . . . . . .. . . . . . . . . . . . 647 Turning Track Changes on and off . . . . . . . . . . . . . . . . . . . . 647 Reviewing the changes . . . . . . . . . . . . . .. . . . . . . . . . . . 649Chapter 33: Making Your Worksheets Error-Free . . . . . . . . . . . 651 Finding and Correcting Formula Errors . . . .. . . . . . . . . . . . . . . . 651Mismatched parentheses . . . . . . . . .. . . . . . . . . . . . . . . . 652Cells are filled with hash marks . . . . .. . . . . . . . . . . . . . . . 653Blank cells are not blank . . . . . . . . . . . . . . . . . . . . . . . . . 654Formulas returning an error . . . . . . . . . . . . . . . . . . . . . . . 654Absolute/relative reference problems . .. . . . . . . . . . . . . . . . 658Operator precedence problems . . . . .. . . . . . . . . . . . . . . . 659Formulas are not calculated . . . . . . . . . . . . . . . . . . . . . . . 659Actual versus displayed values . . . . . .. . . . . . . . . . . . . . . . 660Floating point number errors . . . . . . .. . . . . . . . . . . . . . . . 660Phantom link errors . . . . . . . . . . . . . . . . . . . . . . . . . . . 662 Using Excels Auditing Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . 662Identifying cells of a particular type . . .. . . . . . . . . . . . . . . . 662Viewing formulas . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 663Comparing two windows . . . . . . . . . . . . . . . . . . . . . . . . . 664Tracing cell relationships . . . . . . . . .. . . . . . . . . . . . . . . . 665Tracing error values . . . . . . . . . . . .. . . . . . . . . . . . . . . . 667Fixing circular reference errors . . . . . .. . . . . . . . . . . . . . . . 667Using background error-checking feature . . . . . . . . . . . . . . . . 667Using Excel Formula Evaluator . . . . . . . . . . . . . . . . . . . . . . 669 Searching and Replacing . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 670Searching for information . . . . . . . . . . . . . . . . . . . . . . . . . 670Replacing information . . . . . . . . . . . . . . . . . . . . . . . . . . . 671Searching for formatting . . . . . . . . . .. . . . . . . . . . . . . . . . 671 33. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxxi Contentsxxxi Spell Checking Your Worksheets . . . . . . . . . . . . . . . . . . . . . . . . 672 Using AutoCorrect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673 Using AutoComplete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 Part VI: Programming Excel with VBA 677Chapter 34: Introducing Visual Basic for Applications . . . . . . . . 679 Introducing VBA Macros . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 679 Two Types of VBA Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680 VBA Sub procedures . . . . . . . . .. . . . . . . . . . . . . . . . . . . 680 VBA functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 Creating VBA Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 Recording VBA macros . . . . . . .. . . . . . . . . . . . . . . . . . . 683 More about recording VBA macros . . . . . . . . . . . . . . . . . . . 689 Writing VBA code . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 691 Learning More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 Read the rest of the book . . . . . . . . . . . . . . . . . . . . . . . . . 702 Record your actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 Use the online Help system . . . . .. . . . . . . . . . . . . . . . . . . 702 Get another book . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 702Chapter 35: Creating Custom Worksheet Functions . . . . . . . . . . 703 Overview of VBA Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 An Introductory Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 A custom function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 Using the function in a worksheet . . . . . . . . . . . . . . . . . . . . 704 Analyzing the custom function . . . . . . . . . . . . . . . . . . . . . . 705 About Function Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 Executing Function Procedures . . . . . . . . . . . . . . . . . . . . . . . . . 706 Calling custom functions from a procedure . . . . . . . . . . . . . . . 707 Using custom functions in a worksheet formula . . . . . . . . . . . . 707 Function Procedure Arguments . . . . . . . . . . . . .. . . . . . . . . . . . 708 A function with no argument . . . . . . . . . . . . . . . . . . . . . . . 708 A function with one argument . . . . . . . . . .. . . . . . . . . . . . 709 A function with two arguments . . . . . . . . . . . . . . . . . . . . . . 710 A function with a range argument . . . . . . . .. . . . . . . . . . . . 711 Debugging Custom Functions . . . . . . . . . . . . . .. . . . . . . . . . . . 712 Inserting Custom Functions . . . . . . . . . . . . . . .. . . . . . . . . . . . 712 Learning More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714Chapter 36: Creating UserForms . . . . . . . . . . . . . . . . . . . . . 715 Why Create UserForms? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 UserForm Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716The InputBox function. . . . . . . . . . . . . . . . . . . . . . . . . . . 716The MsgBox function. . . . . . . . . . . . . . . . . . . . . . . . . . . 717 34. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxxii xxxiiContents Creating UserForms: An Overview . . . . . . . . . . . . .. . . . . . . . . . 720Working with UserForms . . . . . . . . . . . . . . .. . . . . . . . . . 720Adding controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720Changing the properties of a control . . . . . . . .. . . . . . . . . . 722Handling events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723Displaying a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 A UserForm Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723Creating the UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . 724Testing the UserForm . . . . . . . . . . . . . . . . .. . . . . . . . . . 725Creating an event handler procedure . . . . . . . . . . . . . . . . . . 725 Another UserForm Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 726Creating the UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . 727Testing the UserForm . . . . . . . . . . . . . . . . .. . . . . . . . . . 728Creating event handler procedures . . . . . . . . . . . . . . . . . . . 729Testing the UserForm . . . . . . . . . . . . . . . . .. . . . . . . . . . 730Making the macro available from a toolbar button. . . . . . . . . . 731 More on Creating UserForms . . . . . . . . . . . . . . . . . . . . . . . . . . 731Adding accelerator keys . . . . . . . . . . . . . . . . . . . . . . . . . . 732Controlling tab order . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 Learning More . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 732Chapter 37: Using UserForm Controls in a Worksheet . . . . . . . . 733 Why Use Controls on a Worksheet? . . . . . . . . . . . . . . . . . . . . . . 733 Using Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735Adding a control . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 735About design mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736Adjusting properties . . . . . .. . . . . . . . . . . . . . . . . . . . . . 736Common properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737Linking controls to cells . . . . . . . . . . . . . . . . . . . . . . . . . . 738Creating macros for controls .. . . . . . . . . . . . . . . . . . . . . . 738 The Controls Toolbox Controls . . .. . . . . . . . . . . . . . . . . . . . . . 739CheckBox control . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 739ComboBox control . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 740CommandButton control . . . . . . . . . . . . . . . . . . . . . . . . . 740Image control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741Label control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741ListBox controls . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 741OptionButton controls . . . . . . . . . . . . . . . . . . . . . . . . . . . 741ScrollBar control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742SpinButton control . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 743TextBox controls . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 743ToggleButton control . . . . .. . . . . . . . . . . . . . . . . . . . . . 744Chapter 38: Working with Excel Events . . . . . . . . . . . . . . . . . 745 Understanding Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745 Entering event handler VBA code . . . . . . . . . . . . . . . . . . . . 746 35. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxxiiiContentsxxxiii Using Workbook-Level Events . . . . . . . . . .. . . . . . . . . . . . . . . . 747Using the Open event . . . . . . . . . . .. . . . . . . . . . . . . . . . 749Using the SheetActivate event . . . . . . . . . . . . . . . . . . . . . . 750Using the NewSheet event . . . . . . . . .. . . . . . . . . . . . . . . . 750Using the BeforeSave event . . . . . . . .. . . . . . . . . . . . . . . . 750Using the BeforeClose event . . . . . . . . . . . . . . . . . . . . . . . 751 Working with Worksheet Events . . . . . . . .. . . . . . . . . . . . . . . . 751Using the Change event . . . . . . . . . .. . . . . . . . . . . . . . . . 752Monitoring a specific range for changes . . . . . . . . . . . . . . . . 752Using the SelectionChange event . . . . . . . . . . . . . . . . . . . . . 753Using the BeforeRightClick event . . . .. . . . . . . . . . . . . . . . 754 Using Non-Object Events . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 754Using the OnTime event . . . . . . . . . .. . . . . . . . . . . . . . . . 755Using the OnKey event . . . . . . . . . . . . . . . . . . . . . . . . . . 755Chapter 39: VBA Examples . . . . . . . . . . . . . . . . . . . . . . . . . 757 Working with Ranges . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 757Copying a range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758Copying a variable-size range . . . . . . . . . . . . . . . . . . . . . . . 759Selecting to the end of a row or column . . . . . . . . . . . . . . . . . 759Selecting a row or column . . . . . . . . . . . . . . . . . . . . . . . . . 760Moving a range . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 760Looping through a range efficiently . . . . . . . . . . . . . . . . . . . 761Prompting for a cell value . . . . . . . .. . . . . . . . . . . . . . . . . 762Determining the type of selection . . . . . . . . . . . . . . . . . . . . 763Identifying a multiple selection . . . . .. . . . . . . . . . . . . . . . . 764 Changing Excels Settings . . . . . . . . . . .. . . . . . . . . . . . . . . . . 764Changing Boolean settings . . . . . . . . . . . . . . . . . . . . . . . . 765Changing non-Boolean settings . . . . . . . . . . . . . . . . . . . . . . 765 Working with Charts . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 766Modifying the chart type . . . . . . . .. . . . . . . . . . . . . . . . . 766Modifying chart properties . . . . . . .. . . . . . . . . . . . . . . . . 767Applying chart formatting . . . . . . . . . . . . . . . . . . . . . . . . . 767 VBA Speed Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768Turning off screen updating . . . . . . . . . . . . . . . . . . . . . . . 768Preventing alert messages . . . . . . . . . . . . . . . . . . . . . . . . 768Simplifying object references . . . . . . . . . . . . . . . . . . . . . . . 769Declaring variable types . . . . . . . . .. . . . . . . . . . . . . . . . . 769Chapter 40: Creating Custom Excel Add-Ins . . . . . . . . . . . . . . 773 What Is an Add-In? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773 Working with Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774 Why Create Add-Ins? . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . 775 Creating Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776 An Add-In Example . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . 777Setting up the workbook . . . . . . . . . . . . . . . . . . . . . . . . . 777Module1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778 36. 01 539671 FM.qxd 8/28/03 9:59 AM Page xxxivxxxiv Contents ThisWorkbook . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 778 UserForm1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779 Testing the workbook . . . . . .. . . . . . . . . . . . . . . . . . . . . 780 Adding descriptive information. . . . . . . . . . . . . . . . . . . . . 781 Protecting the project . . . . . .. . . . . . . . . . . . . . . . . . . . . 782 Creating the add-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 782 Opening the add-in . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 783 Part VII: Appendixes785Appendix A: Worksheet Function Reference . . . . . . . . . . . . . . 787Appendix B: Whats on the CD-ROM . . . . . . . . . . . . . . . . . . . 803Appendix C: Just for Fun . . . . . . . . . . . . . . . . . . . . . . . . . . 815Appendix D: Additional Excel Resources . . . . . . . . . . . . . . . . 837Appendix E: Excel Shortcut Keys . . . . . . . . . . . . . . . . . . . . . 845Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853End-User License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . 899 37. 02 539671 pp01.qxd 8/28/03 9:59 A