Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Bold a certain word throughout worksheet

How do I bold a particular word throughout my entire worksheet?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Bold a certain word throughout worksheet

Try this one for the word ron

Sub MakeBold()
Dim FirstAddress As String
Dim MyArr As Variant
Dim Rng As Range
Dim I As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Search for a Value Or Values in a range
'You can also use more values like this Array("ron", "dave")
MyArr = Array("ron")

'Search range
With Sheets("Sheet1").UsedRange


For I = LBound(MyArr) To UBound(MyArr)

'If you want to find a part of the rng.value then use xlPart
'if you use LookIn:=xlValues it will also work with a
'formula cell that evaluates to "ron"

Set Rng = .Find(What:=MyArr(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rng.Font.Bold = True
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < FirstAddress
End If
Next I
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"suestew" wrote in message ...
How do I bold a particular word throughout my entire worksheet?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Bold a certain word throughout worksheet

A much simpler way is to do this:

Sheets("Sheet1").Select 'Or whatever worksheet it is
With Application.ReplaceFormat.Font
.FontStyle = "Bold"
End With
Cells.Replace What:="Ron", Replacement:="Ron", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True


"Ron de Bruin" wrote:

Try this one for the word ron

Sub MakeBold()
Dim FirstAddress As String
Dim MyArr As Variant
Dim Rng As Range
Dim I As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Search for a Value Or Values in a range
'You can also use more values like this Array("ron", "dave")
MyArr = Array("ron")

'Search range
With Sheets("Sheet1").UsedRange


For I = LBound(MyArr) To UBound(MyArr)

'If you want to find a part of the rng.value then use xlPart
'if you use LookIn:=xlValues it will also work with a
'formula cell that evaluates to "ron"

Set Rng = .Find(What:=MyArr(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rng.Font.Bold = True
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < FirstAddress
End If
Next I
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"suestew" wrote in message ...
How do I bold a particular word throughout my entire worksheet?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Bold a certain word throughout worksheet

Hi LOFE

I agree with you in this case

With the macro I posted you can do a lot more but that is not needed in this case.

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"LOFE" wrote in message ...
A much simpler way is to do this:

Sheets("Sheet1").Select 'Or whatever worksheet it is
With Application.ReplaceFormat.Font
.FontStyle = "Bold"
End With
Cells.Replace What:="Ron", Replacement:="Ron", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True


"Ron de Bruin" wrote:

Try this one for the word ron

Sub MakeBold()
Dim FirstAddress As String
Dim MyArr As Variant
Dim Rng As Range
Dim I As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Search for a Value Or Values in a range
'You can also use more values like this Array("ron", "dave")
MyArr = Array("ron")

'Search range
With Sheets("Sheet1").UsedRange


For I = LBound(MyArr) To UBound(MyArr)

'If you want to find a part of the rng.value then use xlPart
'if you use LookIn:=xlValues it will also work with a
'formula cell that evaluates to "ron"

Set Rng = .Find(What:=MyArr(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rng.Font.Bold = True
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < FirstAddress
End If
Next I
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"suestew" wrote in message ...
How do I bold a particular word throughout my entire worksheet?


Reply
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
How to concatonate two words with first word in BOLD format? nculbert Excel Discussion (Misc queries) 3 February 22nd 10 10:20 PM
Make 1st word in cell bold after combining words from two cells [email protected] Excel Programming 10 June 5th 08 06:31 PM
Assign Bold Feature to one of the Word in a Cell Akash Excel Programming 1 July 30th 07 12:26 PM
Paste chart to word-lose bold type kate New Users to Excel 1 November 21st 06 11:16 AM
Is it possible to make a word in a formula bold? SpielbergRules Excel Worksheet Functions 5 July 2nd 06 06:59 PM


All times are GMT +1. The time now is 03:46 PM.

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

About Us

"It's about Microsoft Excel"