One way:
Instead of the formula, use an event macro. Put this in your worksheet
code module (right-click the worksheet tab and choose View Code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sInsertAddr As String = "A3" 'change to suit
Dim sFirst As String
Dim sSecond As String
Dim nLen As Long
If Not Intersect(Target, Range("A1:A2")) Is Nothing Then
sFirst = Range("A1").Text
nLen = Len(sFirst)
sSecond = Range("A2").Text
With Range(sInsertAddr)
.Value = sFirst & " " & sSecond
.Characters(1, nLen).Font.Color = RGB(255, 0, 0)
.Characters(nLen + 2).Font.Color = RGB(0, 0, 255)
End With
End If
End Sub
In article
<22571fcd-37f9-4b26-b956-(E-Mail Removed)>,
angelasg <(E-Mail Removed)> wrote:
> If I hard code a text string in a cell, I can highlight part of the
> cell and make the text red, for example, and then highlight the rest
> of the text and make it blue.
>
> I want to concatenate two text strings like =A1&" "&A2
>
> I want what is in A1 to be red and what is in A2 to be blue.
>
> I thought custom functions like =red(A1)&" "&blue(A2) might work, but
> I can't figure out how to write the code.
>
> Is a custom function the best option? Is there a simpler way? Is it
> possible? Any help would be appreciated.
>
> Thanks.
> Angela
|