Microsoft Office Tutorials and References
In Depth Information
Properties and Methods
If you’d like to delete the values in a range but keep the formatting, use the ClearContents
method of the Range object.
Most methods also take arguments to define the action further. Here’s an example that copies
cell A1 to cell B1 by using the Copy method of the Range object. In this example, the Copy
method has one argument (the destination of the copy). Notice that I use the line continuation
character sequence (a space followed by an underscore) in this example. You can omit the line
continuation sequence and type the statement on a single line.
Specifying arguments for methods and
An issue that often leads to confusion among new VBA programmers concerns arguments for
methods and properties. Some methods use arguments to further clarify the action to be taken,
and some properties use arguments to further specify the property value. In some cases, one or
more of the arguments are optional.
If a method uses arguments, place the arguments after the name of the method, separated by
commas. If the method uses optional arguments, you can insert blank placeholders for the
optional arguments. Later in this sidebar, I show you how to insert these placeholders.
Consider the Protect method for a workbook object. Check the Help system, and you’ll find
that the Protect method takes three arguments: password, structure, and windows. These
arguments correspond to the three options in the Protect Structure and Windows dialog box.