one way:
Sub test()
aString = "Hello World!"
bString = "Adios World"
ActiveCell.Value = aString & " " & bString
With ActiveCell
.Font.ColorIndex = 5
.Characters(1, Len(aString)).Font.ColorIndex = 3
End With
End Sub
--
Gary
- Show quoted text -
Thanks, Gary!
I did adapt your suggestion. However, I am having difficulty applying
it to my situation. Here is the code (from a userform Label_Click
event) I am using.
Private Sub AcceptStatus()
Dim i As Long
For i = 1 To 3
If Me.Controls("Checkbox" & i).Value = True Then aString =
Me.Controls("Checkbox" & i).Caption
Next i
If iStatus = "Work & Reschedule" Then aString = "Work & Reschedule" &
" (" & TextBox3.Text & " for " & TextBox4.Text & ")"
For i = 4 To 10
If Me.Controls("Checkbox" & i).Value = True Then bString =
Me.Controls("Checkbox" & i).Caption
Next i
If Not TextBox1.Text = "" Then bString = TextBox1.Text
cString = Me.TextBox2.Text
ActiveCell.Value = ""
i = Len(ActiveCell.Value)
ActiveCell.Value = aString
ActiveCell.Characters(i + 1).Font.ColorIndex = 3
If Not bString = "" Then
i = Len(ActiveCell.Value)
ActiveCell.Value = ActiveCell.Value & " ~ "
ActiveCell.Characters(i + 1).Font.ColorIndex = 1
i = Len(ActiveCell.Value)
ActiveCell.Value = ActiveCell.Value & itext
ActiveCell.Characters(i + 1).Font.ColorIndex = 11
End If
If Not cString = "" Then
i = Len(ActiveCell.Value)
ActiveCell.Value = ActiveCell.Value & "~"
ActiveCell.Characters(i + 1).Font.ColorIndex = 1
i = Len(ActiveCell.Value)
ActiveCell.Value = ActiveCell.Value & cString
ActiveCell.Characters(i + 1).Font.ColorIndex = 52
End If
End Sub
The problem is each time ActiveCell.Value=ActiveCell.Value & whatever
is used, all of the text to that point becomes the color of the first
text added. Any suggestions?
Thanks,
Mac