Microsoft Office Tutorials and References
In Depth Information
Working with Ranges
h Functions that are useful in your VBA procedures
h Functions that you can use in worksheet formulas
h Windows API calls
Subsequent chapters in this topic present additional feature-specific examples: charts,
pivot tables, events, UserForms, and so on.
Working with Ranges
The examples in this section demonstrate how to manipulate worksheet ranges with VBA.
Specifically, I provide examples of copying a range, moving a range, selecting a range, identifying
types of information in a range, prompting for a cell value, determining the first empty cell in a
column, pausing a macro to allow the user to select a range, counting cells in a range, looping
through the cells in a range, and several other commonly used range-related operations.
Copying a range
Excel’s macro recorder is useful not so much for generating usable code, but for discovering the
names of relevant objects, methods, and properties. The code that’s generated by the macro
recorder isn’t always the most efficient, but it can usually provide you with several clues.
For example, recording a simple copy-and-paste operation generates five lines of VBA code:
Sub Macro1()
Application.CutCopyMode = False
End Sub
Using the examples in this chapter
Not all the examples in this chapter are intended to be stand-alone programs. They are,
however, set up as usable procedures that you can adapt for your own applications.
I urge you to follow along on your computer as you read this chapter. Better yet, modify the
examples and see what happens. I guarantee that this hands-on experience will help you more
than reading a reference book.
Search JabSto ::

Custom Search