PC Review


Reply
Thread Tools Rate Thread

How can I add formatted text to a cell?

 
 
=?Utf-8?B?c2NhYkhlYWQ=?=
Guest
Posts: n/a
 
      28th Nov 2006
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxvaw==?=
Guest
Posts: n/a
 
      28th Nov 2006
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

"scabHead" wrote:

> 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.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking a text formatted cell to a formula cell lacy Microsoft Excel Misc 2 22nd May 2009 03:19 PM
linking a text formatted cell to a formula cell lacy Microsoft Excel Misc 0 22nd May 2009 03:11 PM
A lot of #'s in my text-formatted cell... DeeDeeCee Microsoft Excel Misc 2 2nd Nov 2008 12:12 PM
Converting 'General' formatted cells to Text formatted cell using. =?Utf-8?B?WmFoaWQgS2hhbg==?= Microsoft Excel Worksheet Functions 1 12th Mar 2005 07:13 PM
Text not displayed when cell formatted as text. Duncan Bachen Microsoft Excel Discussion 7 22nd Jun 2004 03:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 PM.