Font and Subscript Question

H

hoising8

I have this text string containing formulas. ="Qo = "&(ROUND(AG41,2))&" /
("&AB30&" x "&(ROUND(AG30/AB30,2))&")". I want to have the answer to
(ROUND(AG30/AB30,2)) show up as a different color. When I highlight the text
and then click the font color button, no colors are available. How do I do
that? Also, I would like to subscript the o in Qo. How would I do this?
Thanks a lot for your help.
 
J

JE McGimpsey

You'd need to replace your formula with a VBA event macro. You could do
something like

Private Sub Worksheet_Calculate()
Const sF1 As String = "Qo = "
Const sF2 As String = " / ("
Const sF3 As String = " x "
Const sF4 As String = ")"
Dim sV1 As String
Dim sV2 As String
Dim sV3 As String

sV1 = Format(Application.Round(Range("AG41").Value, 2), "0.00")
sV2 = Format(Range("AB30").Value, "0.00")
sV3 = Format(Application.Round(Range("AG30").Value / _
Range("AB30").Value, 2), "0.00")
With Range("A1")
.Value = sF1 & sV1 & sF2 & sV2 & sF3 & sV3 & sF4
.Characters(2, 1).Font.Subscript = True
.Characters(InStr(.Text, sF3) + Len(sF3), _
Len(sV3)).Font.ColorIndex = 3
End With
End Sub

which puts the formula in A1 (change to suit), and turns the desired
portion red (Font.ColorIndex = 3).
 
Top