Rob Bovey, President of Application Professionals, has developed several Excel add-ins shipped by Microsoft. He coauthored the Microsoft Excel 97 Developers Kit and Excel 2007 VBA Programmer’s Reference.
Dennis Wallentin has developed Excel solutions since the 1980s through his firm, XL-Dennis, based in Östersund, Sweden.
Stephen Bullen, coauthor of The Excel 2007 VBA Programmer’s Reference, owns Office Automation, Ltd., based in Essex, Ireland.
John Green owns Execuplan Consulting, a Sydney, Australia-based consultancy specializing in Excel and Access development.
Bovey, Bullen, and Green hold Microsoft’s prestigious Most Valuable Professional (MVP) honor.
About This Book
Microsoft Excel is much more than just a spreadsheet. With the introduction of the Visual Basic Editor in Excel 97, followed by the significantly improved stability of Excel 2000, Excel became a respected development platform in its own right. Excel applications are now found alongside those based on C++, Java, and the .NET development platform, as part of the core suite of mission-critical corporate applications.
Unfortunately, Excel is still too often thought of as a hobbyist platform, that people only develop Excel applications in their spare time to automate minor tasks. A brief look at many Excel VBA books seems to confirm this opinion. These books focus on the basics of automating Excel tasks using VBA. This book is the first of its kind in providing a detailed explanation of how to use Excel as the platform for developing professional quality applications.
While most other major development platforms seem to have a de facto standard text that explains the commonly agreed best practices for architecting, designing, and developing applications using that platform, until now Excel has not. This book attempts to fill that gap. The authors are professional Excel developers who create Excel-based applications for clients ranging from individuals to the largest multinational corporations. This book explains the approaches we use when designing, developing, distributing, and supporting the applications we write for our clients.
Who Should Read This Book
This is not a beginner-level book. If you do not already have a clear understanding of the core Excel object model and a basic understanding of Excel VBA development this is not the place to start. We assume that readers of this book have already read and (mostly) understood our Excel 2002 or 2007 VBA Programmer’s Reference, John Walkenbach’s Excel Power Programming, or similar titles. This book begins where other Excel VBA books end.
Owners of the first edition of Professional Excel Development have a different decision to make. Should you purchase the second edition? We have made numerous corrections and improvements throughout this edition as well as expanding it with over 300 pages of new material that you simply will not find anywhere else.
In the interest of full disclosure, however, we want to be very clear that the bulk of the new material is aimed at Excel developers who are working with Excel 2007 and Visual Studio 2008. If you own the first edition of this book and your primary focus is developing VBA applications in Excel 2003 and earlier, you will see incremental rather than revolutionary improvements in this edition. We don’t want to discourage you from upgrading to the second edition and would welcome it if you choose to do so. But most of all we want you to be satisfied with our work, so we state the pros and cons of upgrading honestly to help you make an informed decision.
Excel Developer Categories
Excel developers can be divided into five general categories based on their experience and knowledge of Excel and VBA. This book has something to offer each of them, but with a focus on the more advanced topics. Putting yourself into one of these categories might help you decide whether this is the right book for you.
Basic Excel users probably don’t think of themselves as developers at all. Excel is no more than a tool to help them get on with their job. They start off using Excel worksheets as a handy place to store lists or perform simple repetitive calculations. As they discover more Excel features their workbooks may begin to include more complex worksheet functions, pivot tables, and charts. There is little in this book for basic Excel users, although Chapter 4, “Worksheet Design,” details the best practices to use when designing and laying out a worksheet for data entry; Chapter 20, “Data Manipulation Techniques,” explains how to structure a worksheet and which functions and features to use to manipulate their lists; and Chapter 21, “Advanced Charting Techniques,” explains how to get the most from Excel’s chart engine. The techniques suggested in these chapters should help the basic Excel user avoid some of the pitfalls often encountered as their experience and the complexity of their worksheets increase.
Excel power users have a broad understanding of Excel’s functionality and they know which tool or function is best used in a given situation. Power users create complex workbooks for their own use and are often called on to help develop workbooks for their colleagues, or to identify why their colleagues’ workbooks don’t work as intended. Power users occasionally use snippets of VBA, either found on the Internet or created with the macro recorder, but struggle to adapt the code to their needs. As a result, their code tends to be messy, slow, and hard to maintain. While this book is not a VBA tutorial, power users have much to gain from following the best practices we suggest for both worksheets and code modules. Most of the chapters in the book are relevant to power users who have an interest in improving their Excel and VBA development skills.
VBA developers make extensive use of VBA code in their workbooks—often too much. They are typically either power users who started to learn VBA too early or Visual Basic developers who switched to Excel VBA development. While they may be proficient with VBA they believe every problem must have a VBA solution. They tend to lack the experience required to know when a problem is best solved using Excel, when a problem is best solved using VBA, and when the best solution is a combination of the two. Their solutions are often cumbersome, slow, and make poor use of the Excel object model. This book has much to offer VBA developers to improve their use of Excel itself, including best practices for designing worksheets and how to use Excel’s features for data entry, analysis, and presentation. The book also seeks to improve their Excel VBA development skills by introducing advanced coding techniques, detailing VBA best practices, and explaining how to improve VBA code performance.
Excel developers realize that the most efficient and maintainable applications are those that make the most of Excel’s built-in functionality, augmented by VBA where appropriate. They are confident in developing Excel-based applications for their colleagues or as part of an in-house development team. While their knowledge of Excel is put to good use in their applications, their design techniques tend to be limited, and they are reluctant to use other languages and applications to augment their Excel solutions. They have probably read John Walkenbach’s Excel 2003 or 2007 Power Programming and/or our own Excel 2002 or 2007 VBA Programmer’s Reference. Now they need a book to take them to the highest level of Excel application development—that of the professional developer. This is the book to do that.
Professional Excel developers design and develop for their clients or employer Excel-based applications and utilities that are robust, fast, easy to use, maintainable, and secure. While Excel forms the core of their solutions, they use other applications and languages where appropriate, including third-party ActiveX controls, Office automation, Windows API calls, external databases, various standalone programming languages, and XML. This book teaches all of those skills. If you are already a professional Excel developer, you will know that learning never stops and will appreciate the knowledge and best practices presented in this book by four of your peers.
Excel as an Application Development Platform
If we look at Excel as a development platform rather than just a spreadsheet, we find that it provides five fundamental components we can use in our applications:
- The worksheets, charts, and other objects used to create a user interface and presentation layer for data entry and reporting
- The worksheets used as simple data stores for lists, tables, and other information required by our application
- VBA code and UserForms for creating business logic and advanced user interfaces
- Worksheet formulas used as a declarative programming language for high-performance numerical processing
- The Excel object model, allowing programmatic control of (nearly) all of Excel’s functionality, both from within Excel and from outside it
The Worksheet as a Presentation Layer for Data Entry and Reporting
Most people think about Excel in terms of typing numbers into cells, having some calculations update, and seeing a result displayed in a different cell or on a chart. Without necessarily thinking in such terms, they are using the worksheet as a user interface for their data entry and reporting and are generally comfortable with these tasks. The in-cell editing, validation, and formatting features built in to Excel provide a rich and compelling data entry experience, while the charting, cell formatting, and drawing tools provide a presentation-quality reporting mechanism.
It is hard to imagine the code that would be required if we tried to reproduce this experience using the tools available in most other development environments, yet Excel provides these features right out of th...