Why it's impossible to use a format in a function

  • Thread starter Thread starter Alex ST-Pierre
  • Start date Start date
A

Alex ST-Pierre

Hello,

I think there is a bug in excel or something which can
be improved. When I have a text in a cell, I can make a
part of the text in bold. But, if I use a function like
concatenate of different text, it's impossible to make a
part of the text in bold.

example:
=concatenate("texta","textb") Do you know how I can put
the textb in bold?
 
You could investigate using the CHARACTER vba formatting function. This
allows you to selectively format part of a string.
 
VBA has the same problem as a user. If you convert the formula to a value, then
you can do characater by character formatting. But not if it's still a formula.
 
This is what I thought you wanted. TextA goes in cell A1, TextB in A2. Run
the macro, and the concatenated result appears in cell A3 with the TextB
element emboldened.

Option Explicit

Dim Texta As String
Dim Textb As String
Dim L1 As Integer
Dim L2 As Integer
Sub test()

Sheets("Sheet1").Select
Texta = ActiveSheet.Range("A1").Value
Textb = ActiveSheet.Range("A2").Value
L1 = Len(Texta)
L2 = Len(Textb)

With Worksheets("Sheet1").Range("A3")
.Value = Texta & Textb
.Characters(L1 + 1, L2).Font.Bold = True
End With

End Sub
 
Back
Top