The Characters Object

The Characters object represents a contiguous sequence of text characters. The main purpose of the Characters object is to modify a portion of a text string. The syntax is:

RangeObject.Characters(start, length)

where start is the start character number and length is the number of characters. To illustrate, the following code boldfaces the first word in a cell:

Dim rng As Range Set rng = Range("A1")

rng.Characters(1, InStr(rng.Value, " ") - 1).Font.Bold = True The result is shown in Figure 19-23.

Figure 19-23. Boldfacing the first word of a cell

0 0

Post a comment