I have a formula in a cell: CONCATENATE($F$3;" ";"[";ROUND
(F4
;"%";"]";" ";"| ")
I would like to put the cell F3 in bold, but can't figure out how to
do it.
When I select the word, the "bold" icon is greyed out.
Is it possible to do this?
If I understand you correctly, you want to concatenate several items, andwant
only the portion of the concatenation that comes from F3 to be bolded, with the
rest of the string in a normal font.
You cannot do that with the results of a formula or function. You can only
"differentially format" a text string.
One solution would be to use a VBA macro to perform the concatenation, then
write the resulting text string to a cell and differentially format that.
To enter this Macro (Sub), <alt-F11> opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.
To use this Macro (Sub), <alt-F8> opens the macro dialog box. Select the macro
by name, and <RUN>.
You'll probably need to do some editing. And I also note that some of your
"tokens" could be combined into a single string. But maybe you have a reason
for doing it the way you had written.
========================
Option Explicit
Sub Foo()
Dim rg1 As Range, rg2 As Range
Dim rDest As Range
Dim s As String
Set rg1 = Range("F3")
Set rg2 = Range("F4")
Set rDest = Range("G2")
s = rg1.Value & " " & "[" & _
Application.WorksheetFunction.Round( _
rg2.Value, 0) & "%" & "]" & " " & "| "
With rDest
.Clear
.Value = s
.Characters(1, Len(rg1.Value)).Font.Bold = True
End With
End Sub
=========================
--ron