View Single Post
  #1   Report Post  
gvm
 
Posts: n/a
Default changing type style and colour within a worksheet function

In another post, "JE McGimpsey" solved the following
problem:
Is there a way to add formatting to this formula to make the "Time Period: "
bold and leave the rest of it in regular text?
="Time Period: "& TEXT(From2,"mm/dd/yyyy")&" - "&TEXT(To2,"mm/dd/yyyy")


by doing this:
Put this in your worksheet code module (right-click on the worksheet tab
and choose View Code):

Private Sub Worksheet_Calculate()
Const sPREFIX As String = "Time Period: "
With Range("A1")
.Font.Bold = False
Application.EnableEvents = False
.Value = sPREFIX & _
Format(Range("From2").Value, "mm/dd/yyyy - ") & _
Format(Range("To2").Value, "mm/dd/yyyy")
Application.EnableEvents = True
.Characters(1, Len(sPREFIX)).Font.Bold = True
End With
End Sub
---------------------------------------------------------
Is a similar process recommended to change the word "special" to bold and
green in a worksheet function like this: ="the rate is special and equals
the " & average(etc etc
If so, how should the event macro be written?