LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
ADG ADG is offline
external usenet poster
 
Posts: 76
Default Change the Formatting of All Instances of a word in a worksheet in

Hi Jackie,

you can format substrings in cells as suggested above. Your first problen is
to search for the word in the cells, then find its position in the string.
Once you have done this you can apply your formating. Below is an example
from the macro recorder where I applied different formats to part of a
string.

Range("F1").Select
ActiveCell.FormulaR1C1 = "MyClasses.Add item := Inst, key := CStr(Num)"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Arial Unicode MS"
.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:=7).Font
.Name = "Arial Unicode MS"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=10, Length:=1).Font
.Name = "Arial Unicode MS"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=11, Length:=3).Font
.Name = "Arial Unicode MS"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=14, Length:=1).Font
.Name = "Arial Unicode MS"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=15, Length:=8).Font
.Name = "Arial Unicode MS"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=23, Length:=6).Font
.Name = "Arial Unicode MS"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=29, Length:=6).Font
.Name = "Arial Unicode MS"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=35, Length:=10).Font
.Name = "Arial Unicode MS"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub

--
Tony Green


"jaikal24" wrote:


Is there a way to change the formatting (make it bold or change the font
color) of all the instances of a particular word (not the whole cell) in
excel ? I am able to do it in word but would like to use the macro in
excel & power point also. Any help would be appreciated.

Thanks,
Jackie


--
jaikal24
------------------------------------------------------------------------
jaikal24's Profile: http://www.excelforum.com/member.php...o&userid=35213
View this thread: http://www.excelforum.com/showthread...hreadid=549781


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Instances Excel07..Excel Paste Special Menu Uses Word PS daddy_dandy Excel Discussion (Misc queries) 1 April 21st 08 03:55 PM
change the color of one word throughout a worksheet wfbarron Excel Worksheet Functions 3 November 19th 07 08:25 PM
I only want to change the formatting of one word in an Excel cell Mark B Excel Discussion (Misc queries) 2 May 17th 07 06:29 PM
Excel Macro to find instances of a word [email protected] Excel Discussion (Misc queries) 1 April 5th 07 01:30 PM
Find and replace of word causes change of font formatting jwa90010 New Users to Excel 4 July 22nd 05 08:10 PM


All times are GMT +1. The time now is 04:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"