PC Review


Reply
Thread Tools Rate Thread

Changing font within cell using VBA

 
 
stainless
Guest
Posts: n/a
 
      18th Mar 2007
I have a VBA macro in Excel 2003 that puts a word within text already
in a cell. I want this word to appear as normal font when the rest of
the text in the cell is in bold.

How can I define the font of a substring of a cell?

Cheers

Mark

 
Reply With Quote
 
 
 
 
Zack Barresse
Guest
Posts: n/a
 
      18th Mar 2007
Hi Mark,

Have you tried the macro recorder? This should give you the basis of code
you need. Here is an example of recorded macro code...


ActiveCell.FormulaR1C1 = "Hello world"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial Black"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
With ActiveCell.Characters(Start:=6, Length:=6).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With


You can do some things to individual characters within a cell, but not too
much. Hopefully this will get you started though. Don't forget about the
macro recorder!

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"



"stainless" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a VBA macro in Excel 2003 that puts a word within text already
> in a cell. I want this word to appear as normal font when the rest of
> the text in the cell is in bold.
>
> How can I define the font of a substring of a cell?
>
> Cheers
>
> Mark
>


 
Reply With Quote
 
jan
Guest
Posts: n/a
 
      18th Mar 2007
Mark,

You can use the macrorecorder to see what the VBA-code will become if you
change a cell in the way you wish.

Jan



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      18th Mar 2007
and you could refine it to

with ActiveCell 'untested
.font.fontstyle="Bold"
.Characters(Start:=1, Length:=5).Font.FontStyle = "Regular"
end with

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Zack Barresse" <(E-Mail Removed)> wrote in message
news:7097A571-B64B-47E7-B98C-(E-Mail Removed)...
> Hi Mark,
>
> Have you tried the macro recorder? This should give you the basis of code
> you need. Here is an example of recorded macro code...
>
>
> ActiveCell.FormulaR1C1 = "Hello world"
> With ActiveCell.Characters(Start:=1, Length:=5).Font
> .Name = "Arial Black"
> .FontStyle = "Bold"
> .Size = 11
> .Strikethrough = False
> .Superscript = False
> .Subscript = False
> .OutlineFont = False
> .Shadow = False
> .Underline = xlUnderlineStyleNone
> End With
> With ActiveCell.Characters(Start:=6, Length:=6).Font
> .Name = "Arial"
> .FontStyle = "Regular"
> .Size = 11
> .Strikethrough = False
> .Superscript = False
> .Subscript = False
> .OutlineFont = False
> .Shadow = False
> .Underline = xlUnderlineStyleNone
> End With
>
>
> You can do some things to individual characters within a cell, but not too
> much. Hopefully this will get you started though. Don't forget about the
> macro recorder!
>
> --
> Regards,
> Zack Barresse, aka firefytr
> MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"
>
>
>
> "stainless" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have a VBA macro in Excel 2003 that puts a word within text already
>> in a cell. I want this word to appear as normal font when the rest of
>> the text in the cell is in bold.
>>
>> How can I define the font of a substring of a cell?
>>
>> Cheers
>>
>> Mark
>>

>



 
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 in a Cell Robert Sheppard Microsoft Excel Programming 1 31st Aug 2007 06:33 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:32 PM.