I am merging two cells in Excel 2016
=E2&" - "&F2
Now, the text in cell E2 is Normal - the text in cell F2 is Bold
However, when merging the cells the entire text is Normal
If you write in a cell you can choose to make part of the text bold. So two formattings in one cell is possible - but when merging?
Additional info:
After researching the problem, I believe it requires a bit of VBA-script. If you can help with a script that reads the length of first part and then bolds the last part of the text that should do it. However the complete formula is:
=IF(Plan!F2<>"";Plan!E2&" - "&Plan!F2;Plan!E2)
The VBA function I have so far is:
Function boldIt(navn As String, ekstra As String)
Dim ln1 As Integer
Dim ln2 As Integer
ln1 = Len(navn)
ln2 = Len(navn) + Len(ekstra)
If (ln1 = ln2) Then
boldIt = navn
Else
boldIt = navn & " - " & ekstra
boldTxt ln1, ln2
End If
End Function
Public Sub boldTxt(startPos As Integer, charCount As Integer)
With ActiveCell.Characters(Start:=startPos, Length:=charCount).Font
.FontStyle = "Bold"
End With
End Sub
The function takes the content of the two text cells I want to combine
The text is merged correct and the sub-function is called(tested with msgBox)
However, the text is not bolded as I expected