I put on macro recording mode, typed bbbbbbbb in cell A2, then used edit mode to change the middle 2 b's to bold by selecting them and typing ctrl-B, thus giving bbbbbbbb.
This is what the macro-recorder recorded:
Range("A2").Select
ActiveCell.FormulaR1C1 = "bbbbbbbb"
Range("A2").Select
ActiveCell.FormulaR1C1 = "bbbbbbbb"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Arial"
.FontStyle = "Standaard"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=4, Length:=2).Font
.Name = "Arial"
.FontStyle = "Vet"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=6, Length:=3).Font
.Name = "Arial"
.FontStyle = "Standaard"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub
The way to do it might not be elementary, even for an experienced VBA-programmer, the way to find out how Excel does it certainly is!
Kees
I'm writing now convertor from my own Report Component to Microsoft Excel format and have a problem: cannot programmically change font and text format for PARTS of text in cell. It's easy to do by hand, but how can I do it programmically?
Please help me! I have to appear checkboxes and comboboxes in Excel sheet, and decided to do it in following manner:
[x] CheckboxName,
where [x] - symbol with code 0xFD of Wingdings font.
Or, maybe, there are other ideas?