Excel 2010 Power Programming with VBA
by John Walkenbach
Excel 2010 Power Programming with VBA
Published byWiley Publishing, Inc.111 River StreetHoboken, NJ 07030-5774
www.wiley.com
Copyright 2010 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 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-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley and the Wiley Publishing logo 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. Excel is a registered trademark of Microsoft Corporation in the United States and/or other countries. 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 representations 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 created or extended by sales or promotional materials. The advice and strategies contained 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 further 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. FULFILLMENT OF EACH COUPON OFFER IS THE SOLE RESPONSIBILITY OF THE OFFEROR.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wileycom/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: 2010923549
ISBN: 978-0-470-47535-5
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
About the Author
John Walkenbach is author of more than 50 spreadsheet books and lives in southern Arizona. Visit his Web site: http://spreadsheetpagecom .
Publisher's Acknowledgments
We're proud of this book; please send us your comments at http://dummiescusthelpcom . For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media Development
Project Editor: Kelly Ewing
Acquisitions Editor: Katie Mohr
Technical Editor: Todd Meister
Editorial Manager: Jodi Jensen
Media Development Project Manager: Laura Moss-Hollister
Media Development Assistant Project Manager: Jenny Swisher
Media Development Associate Producer: Douglas Kuhn
Media Development Quality Assurance: Marilyn Hummel
Editorial Assistant: Amanda Graham
Sr. Editorial Assistant: Cherie Case
Composition Services
Project Coordinator: Katherine Crocker
Layout and Graphics: Carrie A. Cesavice, Joyce Haughey, Jennifer Mayberry
Proofreaders: Laura L. Bowman, John Greenough
Indexer: Broccoli Information Management
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Composition Services
Debbie Stailey, Director of Composition Services
Introduction
Welcome to Excel 2010 Power Programming with VBA . If your job involves developing Excel workbooks that others will use or if you simply want to get the most out of Excel you've come to the right place.
Topics Covered
This book focuses on Visual Basic for Applications (VBA), the programming language built into Excel (and other applications that make up Microsoft Office). More specifically, it will show you how to write programs that automate various tasks in Excel. This book covers everything from recording simple macros through creating sophisticated user-oriented applications and utilities.
This book does not cover Microsoft Visual Studio Tools for Office (VSTO). VSTO is a relatively new technology that uses Visual Basic .NET and Microsoft Visual C#. VSTO can also be used to control Excel and other Microsoft Office applications.
What You Need to Know
This is not a book for beginning Excel users. If you have no experience with Excel, a better choice might be my Excel 2010 Bible, which provides comprehensive coverage of all the features of Excel. That book is meant for users of all levels.
To get the most out of this book, you should be a relatively experienced Excel user. I didn't spend much time writing basic how-to information. In fact, I assume that you know the following:
How to create workbooks, insert sheets, save files, and so on
How to navigate through a workbook
How to use the Excel Ribbon user interface
How to enter formulas
How to use Excel's worksheet functions
How to name cells and ranges
How to use basic Windows features, such as file management techniques and the Clipboard
If you don't know how to perform the preceding tasks, you could find some of this material over your head, so consider yourself warned. If you're an experienced spreadsheet user who hasn't used Excel 2010, Chapter 2 presents a brief overview of what this product offers.
What You Need to Have
To make the best use of this book, you need a copy of Excel 2010. Although most of the material also applies to Excel 2003 and later versions, I assume that you're using Excel 2010. Although Excel 2007 and Excel 2010 are radically different from their predecessors, the VBA environment hasn't changed at all. If you plan to develop applications that will be used in earlier versions of Excel, I strongly suggest that you don't use Excel 2010 for your development work. Rather, use the earliest version of Excel that the target audience will be using.