The Font property

As I note earlier in this chapter (see "The Cells property"), a property can return an object. Here's another example: A Range object's Font property returns a Font object.

A Font object, as you may expect, has many accessible properties. To change some aspect of a range's font, you must first access the range's Font object and then manipulate the properties of that object. This might be confusing at first but it eventually makes sense.

The following expression returns a Font object for a range:

Range("A1").Font

The following statement sets to True the Bold property of the Font object contained in the Range object. In plain English, this makes the cell display in boldface:

Range("A1").Font.Bold = True

To see other examples of manipulating font objects, record your actions while you modify some of a range's font attributes. See Chapter 6 for more information about recording macros.

Was this article helpful?

0 0

Post a comment