View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Visual Basic/Excel Changing font olor index in part of a string

Hi Al,

See VBA help on the Characters object and the Characters property.

The following inserts some text into A1 on Sheet1 and sets the font of
alternate characters to red:

Sub Tester()
Dim i As Long

With Worksheets("Sheet1").Range("A1")
.Value = "ABRACADABRA"
For i = 1 To Len(.Value) Step 2
.Characters(i, 1).Font.ColorIndex = 3
Next
End With
End Sub

---
Regards,
Norman



"Al Gee" <Al wrote in message
...
I wish to change the font color index in part of a string (using visual
basic) in the same fashion that we can change a highlighted part of a
string
in the editing bar.

VB seems to require that the characters to have their font color index
changed have to be an entire selected cell.