Formating cells with comments attached

  • Thread starter Thread starter Carter
  • Start date Start date
C

Carter

Hi,
I would like to learn if there is way of using a formula to apply
conditional formatting only to cells that have comments attached to
them. I have searched for an answer, but haven't found one yet.
Thanks.
 
Format conditionnel sur commentaire:

http://cjoint.com/?jqg643N3cc

=comment(A2)="XX"

Function Comment(c)
   Application.Volatile
   If c.Comment Is Nothing Then
     Comment = ""
   Else
     Comment = Replace(c.Comment.Text, Chr(10), "")
   End If
End Function

JBhttp://boisgontierjacques.free.fr



- Show quoted text -

OK, although I am very inexperienced with programming, I gather that
you intend for this code:

"Function Comment(c)
Application.Volatile
If c.Comment Is Nothing Then
Comment = ""
Else
Comment = Replace(c.Comment.Text, Chr(10), "")
End If
End Function"

to be placed into a code module for the worsheet, and for the formula,
=comment(A2)="XX", to be placed into the "Format values where this
formula is true:" box of the conditional formatting dialog. Well, I
did all that, chose the format I wanted to be applied, changed "A2" to
be a cell with a comment attached, nothing happened—no formatting, no
error message, nothing.
Am I supposed to replace the "XX" with something specific to my
situation? Or perhaps I misunderstood the idea. Could you please
explain it in greater detail for me?
Thanks.
 
Copy this UDF to a general module in your workbook.

Function IsComment(Cell)
Set cmt = Cell.Comment
If Not cmt Is Nothing Then
IsComment = True
End If
End Function

In CF>Formula is: =IsComment(A1)

Format to a nice color from Pattern


Gord Dibben MS Excel MVP
 
Function of Gord Dibben may be short:

Function IsComment(c)
Application.Volatile
IsComment = Not c.Comment Is Nothing
End Function

http://cjoint.com/?jqrX1HbfG1

JB

OK, although I am very inexperienced with programming, I gather that
you intend for this code:

"Function Comment(c)
   Application.Volatile
   If c.Comment Is Nothing Then
     Comment = ""
   Else
     Comment = Replace(c.Comment.Text, Chr(10), "")
   End If
 
My thanks to you both. I will try this out as soon as I can.- Hide quotedtext -

- Show quoted text -

Well I tried them both and both worked perfectly. Thanks you both very
much.

Russ
 
Back
Top