PC Review


Reply
Thread Tools Rate Thread

Change Format of Only Some Text in Cell

 
 
=?Utf-8?B?cm9hZGtpbGw=?=
Guest
Posts: n/a
 
      19th Jun 2007
The user interface for Excel allows you to select letters or words within a
string of text in a cell and change the format (bold, color, etc.) for just
the selected letters or words. I haven't been able to figure out how to do
this same selective formatting programmatically. Does VBA provide this
capability and, if so, how?

Thanks,
Will
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBIdXNjaGth?=
Guest
Posts: n/a
 
      19th Jun 2007
Look for the "Characters" collection, which presents the text of a cell as a
collection of characters.
--
John Huschka


"roadkill" wrote:

> The user interface for Excel allows you to select letters or words within a
> string of text in a cell and change the format (bold, color, etc.) for just
> the selected letters or words. I haven't been able to figure out how to do
> this same selective formatting programmatically. Does VBA provide this
> capability and, if so, how?
>
> Thanks,
> Will

 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      19th Jun 2007
from the recorder:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/19/2007
'

'
ActiveCell.FormulaR1C1 = "hello world"
With ActiveCell.Characters(Start:=1, Length:=1).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:=2, Length:=3).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=5, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("D9").Select
End Sub

--
Gary''s Student - gsnu200731


"roadkill" wrote:

> The user interface for Excel allows you to select letters or words within a
> string of text in a cell and change the format (bold, color, etc.) for just
> the selected letters or words. I haven't been able to figure out how to do
> this same selective formatting programmatically. Does VBA provide this
> capability and, if so, how?
>
> Thanks,
> Will

 
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
Conditionl format a cell to change text colour PAULANDBEX24 Microsoft Excel Misc 5 7th Oct 2008 08:00 AM
Change cell format from text to general on the fly JSnow Microsoft Excel Misc 9 13th Aug 2008 04:25 PM
can i change the default cell format to text in a new document =?Utf-8?B?amF5?= Microsoft Excel Misc 3 8th Feb 2007 09:40 PM
Change CSV-load cell format from GENERAL to TEXT for numbers? =?Utf-8?B?TW9yZW5hIENocmlzIE1hdHRoZXdz?= Microsoft Excel Misc 1 14th Oct 2005 05:23 PM
Conditional format - change cell colour according to the text within it Ian R Microsoft Excel Worksheet Functions 2 3rd Jun 2004 09:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.