Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Lee Lee is offline
external usenet poster
 
Posts: 38
Default Different colors within on cell.

1 ; 45 ; 0

I want to change the color of each of the above numbers to bold green, 1,
then bold black 45 and finally bold blue 0. Each number in the one cell is
from the following formula: =TEXT(C4,0)&" ; "&TEXT(D4,0)&" ; "&TEXT(E4,0)
It is lack of space on the paper printout that I want to combine the 3 cells
into 1.
Thanks for any help.
Lee


  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,393
Default Different colors within on cell.

It is possible to have the three words in Mom's Apple Pie display in
different colours but there is no way to have a formula deliver three
colours!

How about making the columns narrower?
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Lee" wrote in message
...
1 ; 45 ; 0

I want to change the color of each of the above numbers to bold green, 1,
then bold black 45 and finally bold blue 0. Each number in the one cell is
from the following formula: =TEXT(C4,0)&" ; "&TEXT(D4,0)&" ; "&TEXT(E4,0)
It is lack of space on the paper printout that I want to combine the 3
cells into 1.
Thanks for any help.
Lee



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,624
Default Different colors within on cell.

As Bernard wrote, there's no way to do it with formulae. You COULD do it
by replacing the formula with an Event Macro.

One way:

Put this in the worksheet code module (right-click the worksheet tab and
choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const csTarget As String = "F4" 'change cell reference to suit
Const csS As String = " ; " 'separator string
Const csP As String = "0" 'TEXT() pattern argument
Dim vClr As Variant
Dim vTxt As Variant
Dim nChr As Long
Dim nLB As Long
Dim nLS As Long
Dim nLen As Long
Dim i As Long

With Range("C4:E4")
If Not Intersect(.Cells, Target) Is Nothing Then
nLS = Len(csS)
vClr = Array(vbGreen, vbBlack, vbBlue)
vTxt = Array(Application.Text(.Cells(1).Value, csP), _
Application.Text(.Cells(2).Value, csP), _
Application.Text(.Cells(3).Value, csP))
nLB = LBound(vTxt)
With Range(csTarget)
With .Font
.Bold = False
.ColorIndex = xlColorIndexAutomatic
End With
.Value = vTxt(nLB) & csS & vTxt(nLB + 1) & _
csS & vTxt(nLB + 2)
nChr = 1
For i = nLB To nLB + 2
nLen = Len(vTxt(i))
With .Characters(nChr, nLen).Font
.Bold = True
.Color = vClr(i)
End With
nChr = nChr + nLen + nLS
Next i
End With
End If
End With
End Sub





In article ,
"Lee" wrote:

1 ; 45 ; 0

I want to change the color of each of the above numbers to bold green, 1,
then bold black 45 and finally bold blue 0. Each number in the one cell is
from the following formula: =TEXT(C4,0)&" ; "&TEXT(D4,0)&" ; "&TEXT(E4,0)
It is lack of space on the paper printout that I want to combine the 3 cells
into 1.
Thanks for any help.
Lee

  #4   Report Post  
Posted to microsoft.public.excel.newusers
Lee Lee is offline
external usenet poster
 
Posts: 38
Default Different colors within on cell.

Thanks for your work. I tried but couldn't get it to work using Excel 2007.
I am not very good with macros but trying to learn. Bernard is correct in
that I can reduce the columns and turn the header text to vertical but I
thought it looked better in one column and I learned some more about what
Excel can and can't do.
Thanks again,
Lee

"JE McGimpsey" wrote in message
...
As Bernard wrote, there's no way to do it with formulae. You COULD do it
by replacing the formula with an Event Macro.

One way:

Put this in the worksheet code module (right-click the worksheet tab and
choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const csTarget As String = "F4" 'change cell reference to suit
Const csS As String = " ; " 'separator string
Const csP As String = "0" 'TEXT() pattern argument
Dim vClr As Variant
Dim vTxt As Variant
Dim nChr As Long
Dim nLB As Long
Dim nLS As Long
Dim nLen As Long
Dim i As Long

With Range("C4:E4")
If Not Intersect(.Cells, Target) Is Nothing Then
nLS = Len(csS)
vClr = Array(vbGreen, vbBlack, vbBlue)
vTxt = Array(Application.Text(.Cells(1).Value, csP), _
Application.Text(.Cells(2).Value, csP), _
Application.Text(.Cells(3).Value, csP))
nLB = LBound(vTxt)
With Range(csTarget)
With .Font
.Bold = False
.ColorIndex = xlColorIndexAutomatic
End With
.Value = vTxt(nLB) & csS & vTxt(nLB + 1) & _
csS & vTxt(nLB + 2)
nChr = 1
For i = nLB To nLB + 2
nLen = Len(vTxt(i))
With .Characters(nChr, nLen).Font
.Bold = True
.Color = vClr(i)
End With
nChr = nChr + nLen + nLS
Next i
End With
End If
End With
End Sub





In article ,
"Lee" wrote:

1 ; 45 ; 0

I want to change the color of each of the above numbers to bold green, 1,
then bold black 45 and finally bold blue 0. Each number in the one cell
is
from the following formula: =TEXT(C4,0)&" ; "&TEXT(D4,0)&" ; "&TEXT(E4,0)
It is lack of space on the paper printout that I want to combine the 3
cells
into 1.
Thanks for any help.
Lee



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically change cell colors based on date in cell Greg Excel Discussion (Misc queries) 2 January 27th 09 05:55 PM
Used drawing colors in shapes....lost default colors for "Fill Col Lai704 Excel Discussion (Misc queries) 1 August 20th 08 04:45 AM
Don't print cell colors, Print font colors. klhetrick Excel Discussion (Misc queries) 4 February 13th 08 05:35 PM
Cell colors or text color changing when date in cell gets closer. Chase Excel Worksheet Functions 5 October 19th 06 08:57 AM
Can't format font colors or cell fill-in colors canoeron Excel Discussion (Misc queries) 3 August 22nd 05 11:46 PM


All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"