HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://members.aol.com/dmcritchie/excel/excel.htm
Calle Bokedal <calle_...@hotmail.com> wrote in message news:85je21$3eo$1...@yggdrasil.utfors.se...
Is it possible to have different colors for differents characters in
one cell (in Excel 97)?
I tried to do it manually, and it seems to work when I'm changing color for some chars, but when I confirm (with Enter), all
characters change color.
Thanks!
Calle
>you cannot
> color individual letters or groups within a cell using VBA.
Maybe I am misunderstanding your statement, but this colors individual
letters of a text string in a cell for me - I agree about not being able to
do this with a formula generated string.
Dim rng As Range
Dim i As Long
Dim strLen As Long
Set rng = ActiveCell
strLen = Len(rng.Value)
For i = 1 To strLen
rng.Characters(Start:=i, Length:=1).Font.ColorIndex _
= Rnd() * 56 + 1
Next
End Sub
Regards,
Tom Ogilvy
MVP Excel
David McRitchie <DMcRi...@msn.com> wrote in message
news:#2cTAeXX$GA.70@cpmsnbbsa04...
Of course you can, as long as the cell doesn't contain a formula. If the
cell contains a constant, then you can do something like:
Range("A1").Characters(3, 5).Font.Color = vbRed
Range("A1").Characters(8, 3).Font.Color = vbGreen
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting Services
www.cpearson.com ch...@cpearson.com
Users will love it!
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting Services
www.cpearson.com ch...@cpearson.com
"Tom Ogilvy" <twog...@email.msn.com> wrote in message
news:um2EN7XX$GA....@cppssbbsa02.microsoft.com...
> David,
>
> >you cannot
> > color individual letters or groups within a cell using VBA.
>
> Maybe I am misunderstanding your statement, but this colors individual
> letters of a text string in a cell for me - I agree about not being able
to
> do this with a formula generated string.
>
> Dim rng As Range
> Dim i As Long
> Dim strLen As Long
> Set rng = ActiveCell
> strLen = Len(rng.Value)
> For i = 1 To strLen
> rng.Characters(Start:=i, Length:=1).Font.ColorIndex _
> = Rnd() * 56 + 1
> Next
> End Sub
>
> Regards,
> Tom Ogilvy
> MVP Excel
>
>
>
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting Services
www.cpearson.com ch...@cpearson.com
"David McRitchie" <DMcRi...@msn.com> wrote in message
news:ekCSpXYX$GA.273@cpmsnbbsa04...
> I am amazed at both Chip's and Tom's replies. I also like Chip's
> Christmas light analogy which I can relate with broken bulbs when
> the random number generates a color matching the background <grin>.