Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Fill Color based on Comment Text


Is there a way to change the fill color of all cells in the active sheet
which have comments, based on a specific text string in those comments?

Crude example:

For Each Cell in ActiveSheet Where comment.text ="Test"
Cell.Interior.ColorIndex = xlNone

Thanx.
- Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Fill Color based on Comment Text

Hi Mike,

Try:

Sub aTester01()
Dim rng As Range
Dim rCell As Range
Const sStr As String = "Hi" '<<== Your search string

Set rng = Range("A1:D100") '<<===== CHANGE

On Error Resume Next 'In case no comments found1
Set rng = rng.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If Not rng Is Nothing Then
For Each rCell In rng.Cells
If InStr(1, rCell.Comment.Text, sStr, vbTextCompare) Then
rCell.Interior.ColorIndex = 6
Else
rCell.Interior.ColorIndex = xlNone
End If
Next rCell
End If
End Sub
'<<====================

---
Regards,
Norman



"MikeF" wrote in message
...

Is there a way to change the fill color of all cells in the active sheet
which have comments, based on a specific text string in those comments?

Crude example:

For Each Cell in ActiveSheet Where comment.text ="Test"
Cell.Interior.ColorIndex = xlNone

Thanx.
- Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Fill Color based on Comment Text


Thank you!



"Norman Jones" wrote:

Hi Mike,

Try:

Sub aTester01()
Dim rng As Range
Dim rCell As Range
Const sStr As String = "Hi" '<<== Your search string

Set rng = Range("A1:D100") '<<===== CHANGE

On Error Resume Next 'In case no comments found1
Set rng = rng.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If Not rng Is Nothing Then
For Each rCell In rng.Cells
If InStr(1, rCell.Comment.Text, sStr, vbTextCompare) Then
rCell.Interior.ColorIndex = 6
Else
rCell.Interior.ColorIndex = xlNone
End If
Next rCell
End If
End Sub
'<<====================

---
Regards,
Norman



"MikeF" wrote in message
...

Is there a way to change the fill color of all cells in the active sheet
which have comments, based on a specific text string in those comments?

Crude example:

For Each Cell in ActiveSheet Where comment.text ="Test"
Cell.Interior.ColorIndex = xlNone

Thanx.
- Mike




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 do I fill one cell color with text html/rgb color from another thewris Excel Discussion (Misc queries) 2 January 22nd 09 12:24 AM
Cond. format text color based on another's text color manxman Excel Discussion (Misc queries) 3 August 31st 06 06:27 PM
Cell Fill Color and text color - changes for recipient Shadowman13 Excel Discussion (Misc queries) 0 March 8th 06 11:32 PM
countif based on fill color edmcf@mot Excel Worksheet Functions 1 January 13th 06 02:22 AM
Default cell comment fill color and font size Shadowman13 Excel Discussion (Misc queries) 2 September 28th 05 08:16 PM


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