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

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?
 
H

Hotbird

You could investigate using the CHARACTER vba formatting function. This
allows you to selectively format part of a string.
 
D

Dave Peterson

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.
 
H

Hotbird

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top