VBA Font detail loss
You must set the characters' properties (Bold, Color, Italics, etc.) one
character at a time. Here is a macro that demonstrates the technique...
Sub Test()
Dim J As Long, Start As Long
Dim C As Range, Source As Range, Temp As Range
'.....
'.....
Set Source = Range("B2:B12")
Set Temp = Cells(Cells(Rows.Count, Source.Column).End(xlUp).Row + 1,
Source.Column)
Temp.Value = ActiveCell.Value &
Join(WorksheetFunction.Transpose(Source.Value), "")
For Each C In Union(ActiveCell, Source)
For J = 1 To Len(C.Value)
Start = Start + 1
With Temp.Characters(Start, 1).Font
.Bold = C.Characters(J, 1).Font.Bold
.Color = C.Characters(J, 1).Font.Color
.Italic = C.Characters(J, 1).Font.Italic
End With
Next
Next
Temp.Copy ActiveCell
Temp.Clear
End Sub
Note that I assume your source range of text will *always* be a contiguous
column of values. Making that assumption allows me to concatenate all the
cells in the range using a single statement (see the assignment statement to
the Temp variable).
In my example above, I set the Bold, Color and Italic properties of the
characters. If there are other properties that you might have set in your
characters, then you will have to add them to the lie inside the
With/EndWith block (just follow the structure of the other statements in
it). Also, my code will preserve any font settings you have in the
ActiveCell that you concatenated the source cells with as well.
--
Rick (MVP - Excel)
"Walter Briscoe" wrote in message
...
The following is a slightly simplified extract from some of my code:
POfInterest = ""
For J = 3 To 12
POfInterest = POfInterest & .Cells(J, 2)
Next
End With
ActiveCell = ActiveCell & POfInterest
Font and boldness in .Cells(J, 2) do not get copied to ActiveCell.
How can I ensure such characteristics are copied?
Each field is a mixture of bold and plain text.
--
Walter Briscoe
|