Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CAM CAM is offline
external usenet poster
 
Posts: 65
Default Highlight certain text for the entire workbook.

Hello,

I have code below that I am trying to finish up, but I need some help. The
code is conditional format searching for a partucular word "Treay Year"
highlights the font in bold and in Red font, but this only works for one
sheet. I want to do is the entire workbook not just one sheet. There may
be a workbook with 10 sheets or more. If perhaps there is a better code I
will be open to it. I am using Excel 2007. Can somebody help me? Thank
you in advance.

Sub Highlight
Cells.Select
Selection.FormatConditions.Add Type:=xlTextString, String:="Treaty
Year", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditi ons.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Highlight certain text for the entire workbook.

Wrap you code into a loop that sets the conditional for each sheet....
something like, I also removed all the selections that the macro recorder
creates as these are not required. Notice I have added the
FormatConditions.Delete statement at the beginning, this is because the
conditions are additive, so removing all before adding new is advised,
unless you have already added others you wish to keep?

Dim wS as Worksheet
For Each wS in ActiveWorkbook.Worksheets
With wS.Cells
.FormatConditions.Delete
.FormatConditions.Add Type:=xlTextString, String:="Treaty Year",
TextOperator:=xlContains
.FormatConditions(.FormatConditions.Count).SetFirs tPriority

With .FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With

.FormatConditions(1).StopIfTrue = False

End With
Next wS



--

Regards,
Nigel




"CAM" wrote in message
...
Hello,

I have code below that I am trying to finish up, but I need some help.
The code is conditional format searching for a partucular word "Treay
Year" highlights the font in bold and in Red font, but this only works for
one sheet. I want to do is the entire workbook not just one sheet.
There may be a workbook with 10 sheets or more. If perhaps there is a
better code I will be open to it. I am using Excel 2007. Can somebody
help me? Thank you in advance.

Sub Highlight
Cells.Select
Selection.FormatConditions.Add Type:=xlTextString, String:="Treaty
Year", _
TextOperator:=xlContains

Selection.FormatConditions(Selection.FormatConditi ons.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False

End Sub


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
Counting text within an Entire Workbook Carrie_Loos via OfficeKB.com Excel Worksheet Functions 5 April 9th 10 06:58 PM
i want to highlight entire row when selecting a cell in that row Dino Excel Discussion (Misc queries) 12 March 30th 08 03:59 AM
count text strings in an entire workbook Dave Breitenbach Excel Worksheet Functions 1 September 26th 06 06:29 PM
Formula to highlight an entire row when certain text is present. bcholin Excel Discussion (Misc queries) 3 September 6th 05 07:12 PM
Search should highlight entire row in Excell in red samuel Excel Discussion (Misc queries) 5 December 27th 04 11:49 PM


All times are GMT +1. The time now is 09:35 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"