ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   changing type style and colour within a worksheet function (https://www.excelbanter.com/excel-worksheet-functions/36851-changing-type-style-colour-within-worksheet-function.html)

gvm

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?









All times are GMT +1. The time now is 09:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com