Getting Help

The easiest way to discover the required code to perform an operation is to use the macro recorder. The recorded code is likely to be inefficient, but it will indicate the objects required and the properties and methods involved. If you turn on the recorder to find out how to color the background of a cell, you will get something like the following:

With

Selection.Interior

.Pattern = xlSolid

.PatternColorIndex = 5 6

.Color = 65535

.TintAndShade = 0

.PatternTintAndShade = 0

End With

This with...End With construction is discussed in more detail later in this chapter. It is equivalent to:

Selection.

Interior.

.Pattern = xlSolid

Selection.

Interior.

.PatternColorIndex = 5 6

Selection.

Interior.

.Color = 65535

Selection.

Interior.

.TintAndShade = 0

Selection.

Interior.

.PatternTintAndShade = 0

The lines of code that specify Pattern, TintAndShade, and PatternTintAndShade are unnecessary, because they specify default values. The macro recorder is not sophisticated enough to know what the user does or doesn't want, so it includes everything. However, the recorded code provides the clues you need to get started. You only need to figure out how to change the Range object, Selection, into a complete row or complete column. If this can be done, it will be accomplished by using a property or method of the Range object.

Was this article helpful?

0 0
The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook


Post a comment