ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using bold and normal font within one cell (https://www.excelbanter.com/excel-programming/287247-using-bold-normal-font-within-one-cell.html)

Paul

Using bold and normal font within one cell
 
In Excel you can manually change some of the formatting
for part of a cell. This allows you for example to only
make selected parts of the contents of the cell bold
rather than everything.

Does anyone know how you can do this with VBA?

Don Guillett[_4_]

Using bold and normal font within one cell
 
Here is one I just recorded. Of course it needs a LOT of cleaning up to do
just what you want. But, you get the idea. BTW, you cannot do this with a
formula.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 1/8/2004 by Don Guillett
'

'
Range("E9").Select
ActiveCell.FormulaR1C1 = "Date"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Courier"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=3, Length:=2).Font
.Name = "Courier"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
Range("E5").Select
End Sub


--
Don Guillett
SalesAid Software

"Paul" wrote in message
...
In Excel you can manually change some of the formatting
for part of a cell. This allows you for example to only
make selected parts of the contents of the cell bold
rather than everything.

Does anyone know how you can do this with VBA?




Gord Dibben

Using bold and normal font within one cell
 
Paul

Sub CellFont()
With ActiveCell.Characters(Start:=1, length:=3).Font
.ColorIndex = 3
.Bold = True
.Underline = True
End With
With ActiveCell.Characters(Start:=4, length:=3).Font
.Superscript = True
.ColorIndex = 5
End With
End Sub

Adjust to suit.

Gord Dibben Excel MVP

On Thu, 8 Jan 2004 08:41:48 -0800, "Paul" wrote:

In Excel you can manually change some of the formatting
for part of a cell. This allows you for example to only
make selected parts of the contents of the cell bold
rather than everything.

Does anyone know how you can do this with VBA?




All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com