How can I add formatted text to a cell?

G

Guest

I have some VB code that places formatted text strings in cells. The formats
consist of color as well as italics and underlining. I apply the formatting
using an "objcell.characters(intStart, intLength).Font.Italic" type of
approach. Where I am having trouble is when I want to add more text to the
cell later. The formats seem to shift or change. What might have been
previously not underlined is now underlined for example. The colors tend to
work properly but the italic, bold, or underline settings have been unstable.
For example, the existing string might have been italic and I try to add
plain text to it without affecting the italic stuff. The result might be
either all italic or all plain.

I modify the strings using the formula property and perhaps that is the
problem but I can't seem to think of another way to add text. Should I be
using a different method to build the strings? It really is frustrating
because this should have been the easy part of the code I wrote and it is
killing me. Has anyone else written code that does something similar?

I am sure feeling like an idiot banging my head up against this issue.
 
G

Guest

Hi ScabHead
Have you tried following approach to insert data

Range("A1").Characters(Start:=8,Length:=1).Insert "Y"
This replaces the 8th character

Range("A1").Characters(Start:=8,Length:=0).Insert "Y"
This does not replace any character and adds Y in the 8th position

etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top