ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Different font characteristics in concatenated cell (https://www.excelbanter.com/excel-worksheet-functions/173349-different-font-characteristics-concatenated-cell.html)

[email protected]

Different font characteristics in concatenated cell
 
I have a spreadsheet with the following formula: =IF(F2="",C2,F2&":
"&C2) which produces the desired result of CA: Los Angeles Facility
or if there is no code in F2,
Los Angeles Facility

How do I change the font characteristics of "CA:" in the concatenated
cell? I found the code below, but I'm not smart enough to update the
code from the actual text of " Bold Text " to reference instead (F2)
or the (F2)'s text in the cell with the formula (B2).

Any help is greatly appreciated!


Private Sub Worksheet_Calculate()
Const BoldText As String = " Bold Text "
Const ItalicText As String = " Italic Text "
Const DifferentSizedFontText As String = _
" Different Sized Font "


Application.EnableEvents = False
With Range("B1")
.Value = Range("A1").Text & BoldText & _
Range("A2").Text & ItalicText & _
Range("A3").Text & DifferentSizedFontText
.Characters(InStr(.Text, BoldText), _
Len(BoldText)).Font.Bold = True
.Characters(InStr(.Text, ItalicText), _
Len(ItalicText)).Font.Italic = True
.Characters(InStr(.Text, _
DifferentSizedFontText)).Font.Size = 24
End With
Application.EnableEvents = True
End Sub



All times are GMT +1. The time now is 07:25 PM.

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