View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Nipun Nipun is offline
external usenet poster
 
Posts: 5
Default different text colours in the same cell in excel

Thank You for replying... I understood your logic... I think it should
work... Im new to macros so please can you help me with executing it in
detail...

"JE McGimpsey" wrote:

one way:

Since you can't have multiple font colors in a cell containing a
formula, replace the formula with an event macro:

Put this Event macro in your worksheet code module (right-click the
worksheet tab and choose view Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As Long
With Range("A2:B2")
If Not Intersect(Target, .Cells(1)) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
.Cells(2).Value = .Cells(1).Value
Application.EnableEvents = True
On Error GoTo 0
For i = 1 To Len(.Cells(1).Text)
.Cells(2).Characters(i, 1).Font.ColorIndex = _
.Cells(1).Characters(i, 1).Font.ColorIndex
Next i
End If
End With
End Sub


In article ,
Nipun wrote:

I have a formula which copies the text in cell A2 into B2. The text is typed
in A2 in two different colours but when it is copied into B2 it shows in one
colour. Is it possible for it to show it in the same colours or is it
possible for me to have a function that locates a character and changes the
colour of that character only and not the remaining characters in the cell