PC Review


Reply
Thread Tools Rate Thread

Changing Font in a Cell

 
 
Robert Sheppard
Guest
Posts: n/a
 
      31st Aug 2007
How can I change the font of only a portion of the text within a cell. In my
application I want the first portion of text to be Bold and the second
portion of text to be Italics. This is something you can do within Excel but
I cannot figure out how to do it programatically. I can change the font of
the entire cell but not a portion of it.

Any ideas on how I can accomplish this?


 
Reply With Quote
 
 
 
 
Thulasiram
Guest
Posts: n/a
 
      31st Aug 2007
On Aug 31, 10:06 am, "Robert Sheppard" <shep...@cox.net> wrote:
> How can I change the font of only a portion of the text within a cell. In my
> application I want the first portion of text to be Bold and the second
> portion of text to be Italics. This is something you can do within Excel but
> I cannot figure out how to do it programatically. I can change the font of
> the entire cell but not a portion of it.
>
> Any ideas on how I can accomplish this?


Hi Robert,

Try this and tweak it with the font you want

Sub test()

ActiveCell.FormulaR1C1 = "ABCD EFGH"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=6, Length:=4).Font
.Name = "Bodoni MT Black"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B1").Select

End Sub

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing colour of font for a date in a cell Brian Microsoft Dot NET 0 17th Apr 2008 05:24 PM
Changing font within cell using VBA stainless Microsoft Excel Discussion 3 18th Mar 2007 04:54 PM
Retaining Changing Font Color in Cell =?Utf-8?B?cm9hZGtpbGw=?= Microsoft Excel Programming 3 18th Oct 2006 01:22 PM
Changing Font Colour if cell is certain word? wuming79 Microsoft Excel Discussion 5 12th Jul 2006 03:27 AM
Changing font color in one cell only Barbara Microsoft Access 2 16th Sep 2003 01:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:29 PM.