Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cells with multiple font sizes 1

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I am trying to make a table for agenda items and want to format the column headings. For example the first column is Topic. I want the word "Topic" to be 10pt and bold. In the same cell, I want vba to create a new line and place "(What)", 7pts and not bolded. This way each column has a small description below the header without using up extra cells. To cause a line return I used vbCrLf, but this puts a square box at the end of the first word before the line break. Also, I cant figure out how to cause the different font sizes within the cell. Any ideas?

In the same cell:
Topic <- 10pt, Bold
(What) <- 7pt, regular

.Range("a4, e4").WrapText = True
.Range("a4") = "Topic" & vbCrLf & "What"
.Range("a4").SelStart = 0 - Object doesnt support this property or method
.Range("a4").SelLength = 5
.Range("a4").Selection.Font.Bold = True
.Range("a4").SelStart = 6
.Range("a4").SelLength = (Len(.Range("a4")) - 6)
.Range("a4").Selection.Font.Size = 7
.Columns("a").ColumnWidth = 17
 
Give this is a go (I have made the "What" italic).

With ActiveSheet
.Range("A4").WrapText = True
.Range("A4") = "Topic" & Chr(10) & "What"
With .Range("A4").Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
End With
With .Range("A4").Characters(Start:=7, Length:=4).Font
.Name = "Arial"
.FontStyle = "Italic"
.Size = 7
End With
End With
 
It worked! Thats amazing! I had just given up and used two different cells, one above and one below, and not set the horizontal border between them. This is so much better. Thanks a million!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top