517643 cover 10/9/02 1:28 PM Page Everything you need to know about ■ ■ ■ ■ ■ “Mr Spreadsheet” Presents the Only Definitive Guide to Excel Charts If you thought you knew all that Excel can do, think again! In this comprehensive volume, “Mr Spreadsheet” John Walkenbach begins by explaining Excel’s built-in charting basics and goes on to help you master trendlines, AutoShapes, pivot charts, and dozens of other capabilities in both Excel 2000 and 2002 Using his expert techniques as well as his exclusive Power Utility Pak and JWalk Chart Tools, included on the bonus CD-ROM, you’ll produce polished, professional charts that demand attention While Excel books abound, this is the only one devoted solely to the benefits and features of Excel’s charting capacity *85 -IFBJFf CD-ROM Included “I was astonished by how much I learned from this book — it’s a must-read for anyone who wants to explore the full range of Excel charts” John Walkenbach, principal of JWalk and Associates Inc., is a leading authority on spreadsheet software and creator of the award-winning Power Utility Pak He has written more than 30 spreadsheet books and over 300 articles and reviews for publications including PC World, InfoWorld, and Windows He also maintains the popular Spreadsheet Page at www.j-walk.com/ss –Jon M Peltier, Microsoft Excel MVP CD-ROM Includes EXCEL CHARTS ■ Creating and formatting high-impact charts for business, science, and education Selecting the correct chart for your data Customizing your charts with pictures, graphics, and shapes Understanding the tricks of the trade that enable you to create “impossible” charts Creating easy-to-use interactive charts Using VBA to create and modify charts EXCEL C HARTS John Walkenbach “Mr Spreadsheet,” author of Excel 2002 Power Programming with VBA • Code, scripts, examples, and all sample charts from the book • JWalk Chart Tools, an add-in created by the author that comprises six useful chart-related utilities • Trial version of the author’s award-winning Power Utility Pak Walkenbach System Requirements: PC running Windows 98 or later Microsoft Excel See the “What’s on the CD” Appendix for details and complete system requirements Shelving Category Excel/Spreadsheets Reader Level Intermediate to Advanced Price $44.99 US $67.99 CAN £33.50 UK Cover by: Daniela Richardson ISBN: 0-7645-1764-3 ,!7IA7G4-fbhgei!:P;o;O;t;t Includes Power Utility Pak v5 and more on CD-ROM a517643 FM.F 10/14/02 8:38 AM Page i Excel Charts a517643 FM.F 10/14/02 8:38 AM Page ii a517643 FM.F 10/14/02 8:38 AM Page iii Excel Charts John Walkenbach a517643 FM.F 10/14/02 8:38 AM Page iv Excel Charts 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 Library of Congress Control Number: 2002110312 ISBN: 0-7645-1764-3 Manufactured in the United States of America 10 1O/QR/RR/QS/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) 750-4744 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: permcoordinator@wiley.com LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES 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 Trademarks: Wiley, the Wiley publishing logo and related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc., 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 a517643 FM.F 10/14/02 8:38 AM Page v About the Author John Walkenbach is a leading authority on spreadsheet software and principal of JWalk and Associates Inc., a small San Diego–based consulting firm that specializes in spreadsheet application development John is the author of about 30 spreadsheet books and has written more than 300 articles and reviews for a variety of publications, including PC World, InfoWorld, PC Magazine, Windows, and PC/Computing He also maintains a popular Web site (The Spreadsheet Page, www.j-walk.com/ss) and is the developer of the Power Utility Pak, an award-winning add-in for Microsoft Excel John graduated from the University of Missouri and earned a Masters and Ph.D degree from the University of Montana a517643 FM.F 10/14/02 8:38 AM Page vi Credits ACQUISITIONS EDITOR Greg Croy PROJECT COORDINATOR Nancee Reeves PROJECT EDITOR Susan Christophersen GRAPHICS AND PRODUCTION SPECIALISTS Beth Brooks Jeremey Unger TECHNICAL EDITOR Jon Peltier COPY EDITOR Susan Christophersen EDITORIAL MANAGER Carol Sheehan VICE PRESIDENT AND EXECUTIVE GROUP PUBLISHER Richard Swadley VICE PRESIDENT AND EXECUTIVE PUBLISHER Bob Ipsen EXECUTIVE EDITORIAL DIRECTOR Mary Bednarek QUALITY CONTROL TECHNICIAN Andy Hollandbeck PERMISSIONS EDITORS Laura Moss Carmen Krikorian MEDIA DEVELOPMENT SPECIALIST Megan Decraene PROOFREADING AND INDEXING TECHBOOKS Production Services a517643 FM.F 10/14/02 8:38 AM Page vii For Pamn a517643 FM.F 10/14/02 8:38 AM Page viii i517643 Index.F 510 10/14/02 10:14 AM Page 510 Index Rotate Left tool, Picture toolbar, 190 rows argument, OFFSET function, 216 Rows option button, Chart Wizard, 16 R-squared, calculating, 149–150 Run Macro button, Visual Basic toolbar, 417 S save as gif.xls example on CD, 483 explanation, 454 Save data with table layout option, PivotTable Options dialog box, 313 Save password option, PivotTable Options dialog box, 313 saved charts as GIF files.xls, 481 Scale to fit page option, Page Setup dialog box, 24 Scatter chart, 39 Scatter with lines and no data markers chart, 39 Scatter with lines chart, 39 Scatter with smoothed lines and no data markers chart, 39 Scatter with smoothed lines chart, 39 scope, VBA constants, 395 screen updating, turning off, 455 scripting, Web browser, 474 Scroll Bar control adding to chart, 218–220 creating chart, 218 defining names, 218 example, 217 scrolling chart, 461–462 scrolling stock chart.xls example on CD, 483 explanation, 461 secondary axes.xls example on CD, 476 explanation, 85 Secondary Category Axis chart element, 94 Secondary Value Axis chart element, 94 Secondary Value Axis Title chart element, 94 select row to plot.xls example on CD, 481 explanation, 325 select series with checkboxes.xls example on CD, 479 explanation, 234 selecting data, 12, 14 selecting multiple objects, AutoShapes, 178 self-expanding chart COUNTA function, 212, 216–217 creating chart, 212 importance of, 210 modifying series, 213–214 named formulas, 212–213, 215–216 OFFSET function, 212, 216–217 SERIES formula, 212 Source Data dialog box, 213 specifying larger-than-required range, 211 testing, 214 semitransparent bars, 199–200 semitransparent shape, pasting to series, 442–443 serial number system, date-and-time, 400 series adding with Add Data dialog box, 62–63 adding with drag-and-drop, 60 adding with Paste Special, 60–61 adding with Source Data dialog box, 62 changing name, 69–70 combination chart, 83–87 deleting, 63 deleting name, 70–71 displaying names of, 403 formatting, 104–107 hiding data, 77–78 line, 166–167 missing data, 75–77 name, importance of, 68–69 i517643 Index.F 10/14/02 10:14 AM Page 511 Index noncontiguous range, 73–74 plot order, adjusting, 71–73 range highlighting, changing series data with, 64–65 range names, using in SERIES formula, 78–80 SERIES formula, editing, 66–68 Source Data dialog box, changing series data with, 65–66 unlinking from data range, 81–83 using on different sheets, 74–75 Series Axis chart element, 95 Series chart element, 95 SERIES formula, 68, 456 series in different sheets.xls example on CD, 476 explanation, 75 Series Lines chart element, 95 Series list box, Chart Wizard, 17 series name.xls example on CD, 476 explanation, 70 series order.xls example on CD, 476 explanation, 72 Series tab, Chart Wizard, 16 SeriesCollection object, 417 series_name argument, SERIES formula, 68 SERIESNAME_FROM_SERIES function, 457 series.xls example on CD, 477 explanation, 104 Set print titles option, PivotTable Options dialog box, 313 Set statement, VBA, 395 Set Transparent Color tool, Picture toolbar, 190 shade between lines.xls example on CD, 480 explanation, 268 shadows, AutoShapes, 183 shapes in a chart series.xls example on CD, 478 explanation, 197 shared between lines.xls, 480 single data point charts.xls example on CD, 480 explanation, 249–252 Single data type, VBA, 393 single quotation mark (‘), enclosing worksheet name in, 214 six chart types.xls, 476 size and align charts.xls example on CD, 483 explanation, 449 Sized with Window command, sizes argument, SERIES formula, 68 Sizes panel, Format AutoShape dialog box, 176–177 slope, 149–150 slope calculations.xls example on CD, 477 explanation, 163–165 Smooth lines chart, 50 Smoothed Line option, 349 speed tips, VBA, 455–456 Spinner control, 219, 221–222 square root, calculating, 399 Stack of colors chart, 50 stack order, AutoShapes, 178–179 stacked and grouped.xls example on CD, 480 explanation, 291 Stacked area chart, 40 Stacked bar chart, 32 Stacked column chart, 29 stacked column chart variations.xls example on CD, 480 explanation, 256–258 Stacked line chart, 33 Stacked line with data markers chart, 34 stacked 3-D column chart, 294–295 stacked-column chart, 256–258 stacking charts, 291–292 511 i517643 Index.F 512 10/14/02 10:14 AM Page 512 Index standard deviation, plotting with z-scores, 281–282 standard relative address, 216 Standard Types tab, Chart Wizard, 14 Stars and Banners button, AutoShapes toolbar, 172 step chart.xls example on CD, 480 explanation, 258–260 Stock chart, 28, 45–47, 107 stock charts.xls example on CD, 476 explanation, 45–47 Stop Macro button, Visual Basic toolbar, 417 store sales chart COUNTA function, 212, 216–217 creating chart, 212 importance of, 210 modifying series, 213–214 named formulas, 212–213, 215–216 OFFSET function, 212, 216–217 SERIES formula, 212 Source Data dialog box, 213 specifying larger-than-required range, 211 testing, 214 String data type, VBA, 394 structure argument, Protect method, 412 Sub statement, VBA, 395 Subtotal hidden page items option, PivotTable Options dialog box, 312 Surface chart, 28, 43–44 surface charts.xls example on CD, 476 explanation, 43–44 T table, pivot basic example, 302–304 Column field, 306 copying, 315 Data area, 306 data types, 304–305 definition, 301–302 Grand totals, 306 Group, 306 grouping items, 314 Item, 306 lay out, 309–311 Page field, 306 PivotChart Wizard, 305, 307–309 PivotTable and PivotChart Wizard, 305, 307–309 PivotTable Options dialog box, 312–313 Row field, 307 Source data, 307 specifying data, 307–308 specifying data location, 307 Subtotals, 307 table location, 308–309 Tagged Image File Format (TIF, TIFF), 186 Targa graphics format (TGA), 186 text mistakes, 354 Text property, 410 text time line.xls example on CD, 480 explanation, 274 Texture tab, Fill Effects dialog box, 98 TGA See Targa graphics format thermometer chart, 249–250 3-D chart example, 40, 106 floor, 9, 136 problems with, 349–350 wall, 9, 136 3-d charts.xls example on CD, 475, 477 explanation, 48 3-D clustered bar chart, 32, 106 3-D clustered column chart, 29 3-D column chart, 29 3-D effects, AutoShapes, 183 3-D line chart, 34, 106 i517643 Index.F 10/14/02 10:14 AM Page 513 Index 3-D 100% stacked area chart, 40 3-D 100% stacked bar chart, 32, 106 3-D 100% stacked column chart, 29 3-D pie chart, 36, 106 3d scatter plot - rotate.xls example on CD, 479 explanation, 48, 290–291 3-D stacked area chart, 40 3-D stacked bar chart, 32 3-D stacked column chart, 29 3-D charts, formatting, 135–138 tick marks, formatting, 123–124 TIF See Tagged Image File Format TIFF See Tagged Image File Format timeline, 274 time-scale axis, formatting, 120–122 title adding to chart, 108–109, 411 formatting, 107–110 linking to cell, 109 Titles tab, Chart Wizard, 18 titles.xls example on CD, 477 explanation, 107 transparent column.xls example on CD, 478 explanation, 199 transparent series.xls example on CD, 484 explanation, 443 trapezoid method, 283 trendline adding, 141–144 chart types that support, 140 data appropriate for, 140–141 determining values, 148–150 formatting, 144–145 importance of, 9, 139–140 linear, 145–147 linear forecasting, 147–148 moving average, 156–158 nonlinear, 150–156 Trendline chart element, 95 Trendline Equation chart element, 95 trendline equations.xls example on CD, 477 explanation, 154–156 trigonometric functions, plotting, 362–363 troubleshooting, 484 Tubes chart, 50 TwoColorGradient method, 437 2-D chart, combined with 3-D chart, 293 2-D data range, color gradient contour chart, 475 U unlink charts.xls example on CD, 476 explanation, 82–83 Up-Bars chart element, 95 up/down bars, 168–169 upper case, converting to, 399 Use full page option, Page Setup dialog box, 24 user-defined type.xls example on CD, 476 explanation, 49–50 V value axis compared to category axis, 114–116 definition, scales, formatting, 116–120 Value Axis chart element, 95 Value Axis Title chart element, 95 values argument, SERIES formula, 68 Values property, 456 VALUES_FROM_SERIES function, 457 variable type declarations, 456 Variant data type, VBA, 394 vary column width.xls, 480 VB Editor activating window (Alt+F11), 422 Auto List Members feature, 415 built-in functions, displaying list of, 399 continued 513 i517643 Index.F 514 10/14/02 10:14 AM Page 514 Index VB Editor continued executing macro from, 390 online help (F1), 399 Options dialog box, 415 Require Variable Declaration option, Option dialog box, 396 VBA array declaring, 398 definition, 398 Dim statement, 398 index number, 398 multidimensional, 398–399 Public statement, 398 To keyword, 398 VBA assignment statement ampersand (&), string concatenation operator, 398 And logical operator, 398 asterisk (*), multiplication operator, 398 back slash (\), integer division operator, 398 caret (^), exponentiation operator, 398 equal sign (=), 397–398 examples, 397 Excel formula, similarity to, 397 expression, 397 forward slash (/), division operator, 398 functions, 397 greater than (>), comparative operator, 398 greater than or equal to (>=), comparative operator, 398 less than (