View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Insert Characters in cell with formatted text

On 15 Mar 2006 05:04:35 -0800, "MichaB" wrote:

Hello Community,

I've got a problem with a large Excel-Sheet filled mainly with text.
Each cell contains a formated text (bold, underline, color, ...) with
manual line-wraps (made with ALT-Enter). So far everything works fine,
but now I'm trying to add text to this cell. My first try was

cells(a,b).value =cells(a,b).value + NewText

This set all formats to the format of the first line of cell.

For the next approach I tried using the CHARACTERS-Property.

DLen = Worksheets("LOP").Range("F37").Characters.Count
Set DCh = Worksheets("LOP").Range("F37").Characters(DLen-1, 0)
DCh.Insert NewText

This worked perfectly, except that it only worked for cells with less
than 255 characters. Unfortunately most of the cells have more than 500
characters, even up to 2000 characters. With cells larger than 255
characters simply nothing happened.

Has anyone an idea how to add text to a large cell without destroying
the existing formats?

Thanks in advance.

MichaB


Not sure what you are asking.

c.value = c.value & NewText

or

c.value = c.text & NewText

does not change the cell format on my system.

If you mean that you have different formats for different parts of the string,
in the same cell, then I believe you will have to reset them after writing the
new string to the cell.


--ron