View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default font color of partial cell contents

Greg,

You can replace characters using the Mid "Statement".
However, I am guessing that is not exactly what you are looking for...

Sub MoreTextStuff()
Dim strOld As String
strOld = Range("B5").Text
Mid$(strOld, 300, 5) = "stuff"
Range("B5").Value = strOld
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Greg Wilson"
wrote in message
It isn't the line feed per se but the resetting of the value. It just does
that. That's why Jim set the color after setting the value:

< Range("B5").Value = strName
< Range("B5").Characters(lngCellLength + 1, 255).Font.ColorIndex = 3

Instead of changing the cell's Value property (which will wipe out
character-specific formatting), the Characters method allows you to change a
portion of the text formating while preserving the rest. See also the Insert
and Delete methods. Example:

Range("B5").Characters(12, 4).Font.Color = vbRed
Range("B5").Characters(25, 4).Insert ("Gary") 'Supplants existing characters
Range("B5").Characters(25, 0).Insert ("Gary") 'Inserts without supplanting

However, inserting/deleting will only work up to a max of 255 characters
(inclusive of inserted chars). I hope someone will prove me wrong on this or
suggest a workaround because I have a need for it.

Greg