01_575562 ffirs.qxd 12/13/04 9:33 PM Page iii
Excel Formulas and Functions
FOR
DUMmIES‰
by Ken Bluttman and Peter G. Aitken 01_575562 ffirs.qxd 12/13/04 9:33 PM Page ii 01_575562 ffirs.qxd 12/13/04 9:33 PM Page i
Excel Formulas and Functions
FOR
DUMmIES‰ 01_575562 ffirs.qxd 12/13/04 9:33 PM Page ii 01_575562 ffirs.qxd 12/13/04 9:33 PM Page iii
Excel Formulas and Functions
FOR
DUMmIES‰
by Ken Bluttman and Peter G. Aitken 01_575562 ffirs.qxd 12/13/04 9:33 PM Page iv
Excel Formulas and Functions For Dummies® Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 Copyright © 2005 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada 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 permis- sion 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-8600. 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-4355, e-mail: [email protected]. Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, 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.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP- RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE- ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON- TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR- THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, 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. For technical support, please visit www.wiley.com/techsupport. 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: 2004107915 ISBN: 0-7645-7556-2 Manufactured in the United States of America 10987654321 1O/QU/QR/QV/IN 01_575562 ffirs.qxd 12/13/04 9:33 PM Page v
About the Authors Ken Bluttman has been working as a software developer for 15 years. Ken specializes in VB/VBA based applications, often with an emphasis on Microsoft Office. Ken has written several articles on various computer topics including Office/VBA development, XML, SQL Server, and InfoPath. His most recent book is Developing Microsoft Office Solutions. Ken lives in New York with his wife, son, and dog.
Peter Aitken has been writing about computers and programming for over 10 years, with over 35 books well as hundreds of magazine and trade publication articles to his credit. His recent book titles include Powering Office 2003 With XML, Excel Programming Weekend Crash Course, .NET Graphics and Printing, Visual Basic .NET Programming With Peter Aitken, Office XP Development With VBA, XML the Microsoft Way, Windows Script Host, and Teach Yourself Visual Basic .NET Internet Programming in 21 Days. 01_575562 ffirs.qxd 12/13/04 9:33 PM Page vi
Authors’ Acknowledgments Much activity goes on behind the scenes in bringing a book from idea to real- ity. Many people are involved. We wish to thank the great Wiley staff — Jade Williams, Tom Heine, Elizabeth Kuball, Kerwin McKenzie, and everyone on the Production team — for all their hard work!
— Peter G. Aitken and Ken Bluttman
Thanks to co-author Peter Aitken for his contributions, insights, and sugges- tions. Special thanks to my family for understanding that at times sitting in front of a computer is a priority, even when it means I have to miss some- thing special.
— Ken Bluttman 01_575562 ffirs.qxd 12/13/04 9:33 PM Page vii
Dedication Dedicated to all the ones I love. A special appreciation for Matthew. You keep the shine in my eyes. Gayla, I am very happy we made it through a rough summer.
— Ken Bluttman 01_575562 ffirs.qxd 12/13/04 9:33 PM Page viii
Publisher’s Acknowledgments We’re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/. Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media Composition Development Project Coordinator: Nancee Reeves Project Editor: Jade L. Williams Layout and Graphics: Carl Byers, Andrea Dahl, Acquisitions Editor: Tom Heine Lauren Goddard, Barry Offringa, Copy Editor: Elizabeth Kuball Julie Trippetti Technical Editor: Kerwin McKenzie Proofreaders: Laura Albert, Leeann Harney, Jessica Kramer, Carl Pierce, TECHBOOKS Editorial Manager: Robyn Siesky Production Services Media Development Supervisor: Indexer: TECHBOOKS Production Services Richard Graves Special Help: Microsoft Corporation Editorial Assistant: Adrienne Porter Cartoons: Rich Tennant (www.the5thwave.com)
Publishing and Editorial for Technology Publishing Richard Swadley, Vice President and Executive Group Publisher Barry Pruett, Vice President and Publisher, Visual/Web Graphics Andy Cummings, Vice President and Publisher, Technology Dummies Mary Bednarek, Executive Acquisitions Director, Technology Dummies Mary C. Corder, Editorial Director, Technology Dummies Publishing for Consumer Dummies Diane Graves Steele, Vice President and Publisher Joyce Pepple, Acquisitions Director Composition Services Gerry Fahey, Vice President of Production Services Debbie Stailey, Director of Composition Services 02_575562 ftoc.qxd 12/13/04 9:30 PM Page ix
Contents at a Glance
Introduction ...... 1 Part I: Getting Started with Excel Formulas and Functions ...... 7 Chapter 1: Understanding Fundamentals, Formulas, and Functions ...... 9 Chapter 2: Saving Time with the Insert Function Dialog Box ...... 41 Chapter 3: Understanding Array Formulas and Functions ...... 53 Chapter 4: Correcting Formulas ...... 63 Part II: Evaluating Loans and Investments ...... 79 Chapter 5: Calculating Loan Payments and Interest Rates ...... 81 Chapter 6: Performing Advanced Financial Calculations ...... 97 Part III: Working with Numbers ...... 113 Chapter 7: Using Math Functions to Figure Basic Math Answers ...... 115 Chapter 8: Getting More Advanced with Math ...... 133 Chapter 9: Using Descriptive Statistical Functions ...... 151 Chapter 10: Using Significance Tests ...... 189 Chapter 11: Using Prediction and Probability Functions ...... 199 Part IV: Working with Data ...... 217 Chapter 12: Working with Date Functions ...... 219 Chapter 13: Keeping Track with Time Functions ...... 237 Chapter 14: Using Lookup, Logical, and Reference Functions ...... 245 Chapter 15: Working with Information Functions ...... 273 Chapter 16: Working with Text Functions ...... 287 Chapter 17: Summarizing Data with Database Functions ...... 313 Part V: The Part of Tens ...... 331 Chapter 18: Ten + One Great Tips for Working with Formulas ...... 333 Chapter 19: Top Ten Functions You Must Know to Be an Excel Guru ...... 347 Chapter 20: Ten Cool Things to Do with the Analysis ToolPak Add-In ...... 353 Index ...... 367 02_575562 ftoc.qxd 12/13/04 9:30 PM Page x 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xi
Table of Contents
Introduction...... 1 About This Book ...... 1 How to Use This Book ...... 2 What You Can Safely Ignore ...... 2 Foolish Assumptions ...... 2 How This Book Is Organized ...... 3 Part I: Getting Started with Excel Formulas and Functions ...... 3 Part II: Evaluating Loans and Investments ...... 3 Part III: Working with Numbers ...... 3 Part IV: Working with Data ...... 4 Part V: The Part of Tens ...... 4 Icons Used in This Book ...... 4 Where to Go from Here ...... 5
Part I: Getting Started with Excel Formulas and Functions ...... 7
Chapter 1: Understanding Fundamentals, Formulas, and Functions ...... 9 Working with Excel Fundamentals ...... 10 Understanding workbooks and worksheets ...... 10 Working with rows, columns, cells, and ranges ...... 13 Formatting your data ...... 18 Getting help ...... 20 Gaining the Upper Hand on Formulas ...... 21 Entering your first formula ...... 22 Understanding references ...... 23 Copying formulas with the fill handle ...... 25 Assembling formulas the right way ...... 27 Using Functions in Formulas ...... 29 Looking at what goes into a function ...... 30 Discovering usages of a function’s arguments ...... 31 Nesting functions ...... 35 Using array functions ...... 37 Chapter 2: Saving Time with the Insert Function Dialog Box ...... 41 Getting Familiar with the Insert Function Dialog Box ...... 41 Finding the Correct Function ...... 43 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xii
xii Excel Formulas and Functions For Dummies
Entering Functions Using the Insert Function Dialog Box ...... 44 Selecting a function that takes no arguments ...... 45 Selecting a function that takes arguments ...... 47 Entering cell and range references as function arguments ...... 49 Getting Help while Using the Insert Function Dialog Box ...... 52 Using the Function Arguments Dialog Box to Edit Functions ...... 52 Chapter 3: Understanding Array Formulas and Functions ...... 53 Discovering Arrays ...... 53 Using Arrays in Formulas ...... 55 Working with Functions That Return Arrays ...... 58 Chapter 4: Correcting Formulas ...... 63 Catching Errors as They’re Entered ...... 63 Getting parentheses to match ...... 64 Avoiding circular references ...... 66 Mending broken links ...... 67 Using the formula error checker ...... 70 Auditing Formulas ...... 72
Part II: Evaluating Loans and Investments ...... 79
Chapter 5: Calculating Loan Payments and Interest Rates ...... 81 Understanding How Excel Handles Money ...... 82 Going with the cash flow ...... 82 Formatting for dollars ...... 82 Choosing your separators ...... 84 Figuring the Numbers on Your Loans ...... 85 Calculating loan payments with PMT ...... 86 Using IPMT to calculate interest payments ...... 87 Using PPMT to calculate payments toward principal ...... 89 Calculating the number of payments with NPER ...... 91 Using RATE to calculate the interest rate ...... 92 Using PV to calculate the principal on a loan ...... 94 Chapter 6: Performing Advanced Financial Calculations ...... 97 Looking into the Future with FV ...... 97 Depreciating the Finer Things in Life ...... 100 Calculating straight line depreciation ...... 102 Using the SYD function for accelerated depreciation ...... 103 Creating an accelerated depreciation schedule with the DDB function ...... 104 Calculating a depreciation schedule that starts in the middle of a year ...... 106 Measuring Your Internals ...... 107 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xiii
Table of Contents xiii
Part III: Working with Numbers ...... 113
Chapter 7: Using Math Functions to Figure Basic Math Answers ...... 115 Adding It All Together with the SUM Function ...... 115 Rounding Out Your Knowledge of Rounding Functions ...... 119 Just plain old rounding ...... 120 Rounding in one direction ...... 121 Leaving All the Decimals Behind with the INT Function ...... 127 Leaving Some of the Decimals behind with the TRUNC Function ...... 129 Looking for a Sign ...... 129 Ignoring Signs ...... 131 Chapter 8: Getting More Advanced with Math ...... 133 Using the PI Function to Calculate Circumference and Diameter ...... 133 Generating and Using Random Numbers ...... 134 Determining the Ways Items Can Be Ordered ...... 138 Combining Items with the COMBIN Function ...... 139 Raising Numbers to New Heights with the POWER Function ...... 140 Multiplying Multiple Numbers with the PRODUCT function ...... 141 Using SUMPRODUCT to Multiply and Sum Positional Values in One Step ...... 142 Using What Remains with the MOD Function ...... 144 Getting Just the Answer You Need with SUBTOTAL ...... 146 Using SUMIF to Tally Only What’s Needed ...... 147 Chapter 9: Using Descriptive Statistical Functions ...... 151 Deciding Where the Middle Is with AVERAGE, MEDIAN, and MODE ....152 Deviating from the Middle ...... 157 Measuring variance ...... 157 Analyzing deviations ...... 160 Comparing sets of data for similarity ...... 169 Putting Numbers Where They Belong ...... 173 Going for the Count ...... 184 Chapter 10: Using Significance Tests ...... 189 Testing to the T ...... 190 Comparing Results to an Estimate ...... 194 Chapter 11: Using Prediction and Probability Functions ...... 199 Getting It Straight: Using SLOPE and INTERCEPT to Describe Linear Data ...... 201 What’s in the Future: Using FORECAST, TREND, and GROWTH to Make Predictions ...... 205 Using NORMDIST and POISSON to Determine Probabilities ...... 210 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xiv
xiv Excel Formulas and Functions For Dummies
Part IV: Working with Data ...... 217
Chapter 12: Working with Date Functions ...... 219 Understanding How Excel Handles Dates ...... 219 Formatting Dates ...... 221 Assembling a Date with the DATE Function ...... 222 Breaking Apart a Date with the DAY, MONTH, and YEAR Functions ....223 Isolating the day with the DAY function ...... 223 Isolating the month with the MONTH function ...... 225 Isolating the year with the YEAR function ...... 227 Using DATEVALUE to Convert a Text Date into a Numerical Date ...... 227 Using the TODAY Function to Find Out the Current Date ...... 229 Counting the number of days until Christmas ...... 229 Counting your age, in days ...... 230 Determining the Day of the Week with the WEEKDAY Function ...... 230 Determining How Many Workdays Are in a Range of Dates with NETWORKDAYS ...... 232 Calculating Time between Two Dates with the DATEDIF Function ...... 234 Chapter 13: Keeping Track with Time Functions ...... 237 Understanding How Excel Handles Time ...... 237 Formatting Time ...... 238 Assembling Time with the TIME Function ...... 239 Breaking Apart Time with the HOUR, MINUTE, and SECOND Functions ...... 240 Isolating the hour with the HOUR function ...... 240 Isolating the minute with the MINUTE function ...... 241 Isolating the second with the SECOND function ...... 242 Using the NOW Function to Find Out the Current Time ...... 243 Calculating Elapsed Time over Days ...... 243 Chapter 14: Using Lookup, Logical, and Reference Functions . . . . .245 Testing on One Condition ...... 246 Choosing the Right Value ...... 252 Being Logical About It All ...... 253 Finding Where It Is ...... 256 Looking It Up ...... 264 Using TRANSPOSE To Turn Data on Its Ear ...... 269 Chapter 15: Working with Information Functions ...... 273 Getting Informed with the CELL Function ...... 273 Getting Information about Excel and Your Computer System ...... 278 Finding Out What Is and What Is Not ...... 280 Getting to Know Your Type ...... 284 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xv
Table of Contents xv
Chapter 16: Working with Text Functions ...... 287 Breaking Apart Text ...... 287 Bearing to the left ...... 288 Swinging to the right ...... 289 Staying in the middle ...... 290 Putting Text Together ...... 291 Changing Text ...... 293 Making money ...... 293 Making numbers look like text ...... 295 Repeating text ...... 297 Replacing text ...... 298 Giving text a trim ...... 302 Making a case with the case functions ...... 304 Finding Out about Text ...... 305 Going for perfection with the EXACT function ...... 305 Finding and searching ...... 307 Finding out the long and short of it with the LEN function ...... 311 Chapter 17: Summarizing Data with Database Functions ...... 313 Putting Your Data into a Database Structure ...... 313 Understanding How the Database Functions Work ...... 315 Establishing your database ...... 315 Establishing the criteria area ...... 316 Adding Up Only What Matters with DSUM ...... 320 Going For the Middle with DAVERAGE ...... 321 Counting Only What Counts with DCOUNT ...... 322 Finding the Highest and Lowest Values ...... 324 Using DGET to Find Duplicate Values ...... 325 Getting Criteria to Work the Way You Want ...... 326 Finding records that have values in a range ...... 327 Finding records that must match more than one condition ...... 328 Finding records that match one or more conditions ...... 328 Finding records that match a pattern ...... 329
Part V: The Part of Tens ...... 331
Chapter 18: Ten + One Great Tips for Working with Formulas . . . . .333 Operator Precedence ...... 333 Display Formulas ...... 334 Fixing Formulas ...... 336 Use Absolute References ...... 337 Turn Calc On/Turn Calc Off ...... 337 Use Named Areas ...... 339 02_575562 ftoc.qxd 12/13/04 9:30 PM Page xvi
xvi Excel Formulas and Functions For Dummies
Use Formula Auditing ...... 340 Use Conditional Formatting ...... 341 Use the Conditional Sum Wizard ...... 342 Use the Lookup Wizard ...... 343 Create Your Own Functions ...... 344 Chapter 19: Top Ten Functions You Must Know to Be an Excel Guru ...... 347 SUM ...... 347 AVERAGE ...... 348 COUNT ...... 348 INT and ROUND ...... 349 IF ...... 350 NOW and TODAY ...... 350 HLOOKUP and VLOOKUP ...... 351 ISNUMBER ...... 351 MIN and MAX ...... 351 SUMIF and COUNTIF ...... 352 Chapter 20: Ten Cool Things to Do with the Analysis ToolPak Add-In ...... 353 Work with Hexadecimal, Octal, Decimal, and Binary Numbers ...... 354 Convert Units of Measurement ...... 356 Find the Greatest Common Divisor and the Least Common Multiple ...... 357 Easy Random Number Generation ...... 358 Use Sophisticated Finance Functions ...... 358 Generate Descriptive Statistics ...... 359 Create a Histogram ...... 360 Generate Moving Averages ...... 361 Advanced Random Number Generation ...... 363 Create a Random Sample ...... 364 Index...... 367 03_575562 intro.qxd 12/13/04 9:58 PM Page 1
Introduction
preadsheets are such a mainstay in today’s world that the term spread- Ssheet is just about a household word. Certainly in our homes it is. And we don’t just mean because we write books on Excel. Spouses use Excel to track household expenditures and insurance claims. A neighbor analyzes his eBay transactions in Excel. The local merchant keeps tabs on his store’s inventory on a worksheet.
In the workplace, Excel is one of the most commonly used analysis and report- ing tools. Financial statements, sales reports, inventory, project scheduling, customer activity — so much of this stuff is kept in Excel, and it’s the ability of Excel to manipulate and give feedback about the data that makes it so attractive.
About This Book This book is about the number crunching side of Excel. Formulas are the key- stone to analyzing data, that is, digging out nuggets of important information. What is the average sale? How many times did we do better than average? How many days are left on the project, and how much progress have we made? That sort of thing.
Formulas calculate answers, straight and to the point. But that’s not all. Excel has dozens of built-in functions that calculate everything from a simple aver- age to a useful analysis of your investments to complex inferential statistics. But you don’t have to know it all or use it all — just the parts that are relevant to your work.
This book discusses more than 150 of these functions. But rather than just show their syntax and list them alphabetically like a dictionary, we have assembled them by category and provided real examples of how to use them along with step-by-step instructions. 03_575562 intro.qxd 12/13/04 9:58 PM Page 2
2 Excel Formulas and Functions For Dummies How to Use This Book You do not have to read the book sequentially from start to finish — although you certainly can. Each chapter deals with a specific category of functions — financial in one chapter, statistical in another, and so on. Some categories are split over two or more chapters. We suggest two ways for you to use this book: