Hi Roger,
As Harlan says a font in a formula cell cannot have mixed formats.
One approach would be NOT to write a formula in the cell where you want your
cents to be displayed, and let the following Event code do it for you, along
the lines of Myrna's suggestion.
Select G1 and in the Name box left of input bar type "centsIn" without
quotes. Select the cell where you want the converted cents to be displayed
and name it "centsOut".
Right click the sheet tab > View code and paste following into the module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rIn As Range, rOut As Range, n As Long, s As String
On Error GoTo errH
Set rIn = Range("centsIn")
If Intersect(Target, rIn) Is Nothing Then Exit Sub
Set rOut = Range("centsOut")
If IsNumeric(rIn) Then
s = rIn.Value * 100
Else: s = "error"
End If
n = Len(s)
s = s & " cents US$"
Application.EnableEvents = False
With rOut
.Font.Bold = False
.Value = s
.Characters(1, n).Font.Bold = True
End With
done:
Application.EnableEvents = True
Exit Sub
errH:
s = ""
If rIn Is Nothing Then s = "centsIn"
If rOut Is Nothing Then s = "centsOut"
If s <> "" Then MsgBox s & " does not exist"
GoTo done
End Sub
The reason for naming the cells is the code should work if subsequently you
move them.
Regards,
Peter