skip to main content
Skip header Section
Writing Excel Macros with VBAJune 2002
Publisher:
  • O'Reilly & Associates, Inc.
  • 103A Morris St. Sebastopol, CA
  • United States
ISBN:978-0-596-00359-3
Published:01 June 2002
Pages:
560
Skip Bibliometrics Section
Bibliometrics
Skip Abstract Section
Abstract

From the Publisher:

Despite its powerful feature set, you've probably found that there's a lot that you can't do -- or can't do easily -- through Microsoft Excel's user interface. For instance, have you ever wanted to sort the worksheets in a workbook without dragging and dropping each one individually__ __ Have you ever wanted to select a worksheet whose tab was not shown at the bottom of the workbook's window without scrolling through the tabs of all available worksheets__ __ In fact, you can address these and innumerable other shortcomings and extend your control over Excel by using Visual Basic for Applications (VBA) to control Excel programmatically. Writing Excel Macros with VBA is the introduction to Excel VBA that allows you to do just that.

Newly updated for Excel 2002, Writing Excel Macros with VBA provides Excel users, as well as programmers who are unfamiliar with the Excel object model, with a solid introduction to writing VBA macros and programs for Excel.

Writing Excel Macros with VBA is written in a terse, no-nonsense manner that is characteristic of Steven Roman's straightforward, practical approach. Instead of a slow-paced tutorial with a lot of hand-holding, Roman offers the essential information about Excel VBA that you must master to write macros effectively. This information is reinforced by interesting and useful examples that solve common problems you're sure to have encountered.

Writing Excel Macros with VBA is the book you need to delve into the basics of Excel VBA programming, enabling you to increase your power and productivity when using Microsoft Excel.

Contributors
  • California State University, Fullerton
  • University of Michigan, Ann Arbor

Recommendations

Reviews

Stephen Sugden

I have a strong preference for the Pascal family of languages, although I’m also a heavy user of Microsoft Excel, both for mathematical modeling/simulation, and for mathematics education applications. Thus, I am a somewhat reluctant user of Visual Basic (VB)/Visual Basic for Applications (VBA), and find certain features of the language, such as optional variable declaration and type laxity, somewhat irritating. In this book, Roman clearly states his target readership: Excel users (programmers and nonprogrammers). Although he spends some time in Part 2 (chapters 5 to 8) on the essentials of VBA, it is hard to imagine this section being adequate for those who have done no programming before. For such readers, I would recommend a companion reference with much greater detail on the fundamentals of programming in VB/VBA, such as Zak [1]. Although most of the VBA constructs introduced here are illustrated with short snippets of code, this does not supplant the need for a thorough grounding in modern object-oriented, third-generation language (OO-3GL) programming before venturing into VBA. As for the VBA concepts introduced here, I would have liked to see a small application using a good percentage of these at the end of Part 2. The book provides reasonable coverage of elementary programming concepts and programming styles within the setting and peculiarities of VB/VBA. A good overview of the VBA language is presented, and the author supplies useful illustrations of each major feature. In chapter 6, he discusses named arguments for procedures, in contrast to the positional approach (which VBA also allows). Curiously, VBA uses Pascal syntax for assignment if the named arguments option is used. I find myself in agreement with essentially all of what Roman has to say about programming style. His exhortation to avoid the temptation to not declare variables is illustrated with a useful example of how things can go horribly wrong. He considers modes of parameter passing, and, noting that “many programmers do not have a clear understanding of these concepts,” he covers the two modes available in VBA (byval and byref), with useful examples and discussion. Part 1 (chapters 1 to 4) is concerned with a general introduction to Excel, and to elements of the VBA environment, including the editor, debugger, properties, and code windows. Part 2 (chapters 5 to 8) discusses the VBA language. The unnecessarily large variety of looping constructs in VBA is discussed in chapter 8, and Roman supplies some useful remarks on the subtle distinctions between these varieties of “do loops.” The treatment is scant, however; some more useful examples would improve the discussion, and some recommendations on what to avoid, based on the author’s years of experience in teaching programming, would be welcome here. Getting loops right is one of the trickier parts of programming, especially for beginners, and some more extensive and detailed sage advice here would improve any future edition. Surely the exist ence of so many redundant looping constructs is something only Microsoft can attempt to justify; it not only confuses programmers, especially novices, but must make life needlessly more difficult for Microsoft’s VBA compiler writers as well. Part 3 (chapters 9 to 22) forms most of the remainder of the book. Object models in general are discussed in chapter 9, while the Excel Object Model is treated in chapter 15. Chapter 10 discusses creating an Excel add-in, chapter 11 covers Excel Events, and chapter 12 includes other useful topics, including the creation of menus and toolbars. The example code given here is quite adequate. Chapters 19 to 21, each between 60 and 70 pages, occupy exactly 200 pages: almost half percent of the book, not counting the appendices. The range and chart objects are treated in great detail in chapters 19 and 21, respectively, while pivot tables are dealt with in chapter 20. The book has several useful appendices, but no bibliography, which I found surprising. It is possible that some citations exist within the text, but no discernible references to any of the Microsoft Press books on Excel or, for example, to the well-known books by Walkenbach are to be found. On the other hand, an examination of Walkenbach [2] reveals no bibliography there either. There is a useful index, but for those who wish to try out the longer examples, no CD is provided with the book, although sample code is downloadable from the Web. In summary, this is a competently written volume that provides a well-organized introduction to the intricacies of Excel/VBA programming. It is also reasonably compact, a refreshing change from the huge (over 1000-page) tomes that waste space covering topics that are trivial to many professional users of Excel. One could argue that there is a place for such large volumes, but I welcome the style, content, and compactness of this book by Roman. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.