Skip to Content
Excel® 2007 Bible
book

Excel® 2007 Bible

by John Walkenbach
January 2007
Beginner to intermediate
912 pages
21h 53m
English
Wiley
Content preview from Excel® 2007 Bible

Chapter 44. VBA Examples

<feature><title>In This Chapter</title> </feature>

My philosophy about learning to write Excel macros places heavy emphasis on examples. I’ve found that a well-thought-out example often communicates a concept much better than a lengthy description of the underlying theory. In this book, space limitations don’t allow describing every nuance of VBA, so I’ve prepared many examples. Don’t overlook VBA’s Help system for specific details. To get help while working in the VB Editor window, press F1 or type your search terms into the Type A Question For Help box in the menu bar.

This chapter consists of several examples that demonstrate common VBA techniques. You may be able to use some examples directly, but in most cases, you must adapt them to your own needs. These examples are organized into the following categories:

  • Working with ranges

  • Working with workbooks

  • Working with charts

  • Programming techniques to speed up your VBA code

Working with Ranges

Most of what you do in VBA probably involves worksheet ranges. When you work with range objects, keep the following points in mind:

  • Your VBA code doesn’t need to select a range to do something with the range.

  • If your code does select a range, its worksheet must be active.

  • The macro recorder doesn’t always generate the most efficient code. Often, you can use the recorder to create your macro and then edit the code to make it more efficient.

  • I recommend that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel® 2010 Bible

Excel® 2010 Bible

John Walkenbach
Excel® 2007 Charts

Excel® 2007 Charts

John Walkenbach

Publisher Resources

ISBN: 9780470044032Purchase book