Conditional Format Comment?

leonem

New Member
Joined
Apr 5, 2006
Messages
36
Is there a way to set a conditional format so that if it meets my desired conditions I can have a predetermined comment inserted? I have never seen anything like this so dont know if it is possible.

Thanks
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Hello: Maybe with a little code. Using the WorkSheet_Change Event, something like this
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address <> "$C$4" Then Exit Sub
    If Target > 100 Then
        Target.ClearComments
        Target.AddComment ("Comment 1")
        Exit Sub
    End If
    If Target > 50 Then
        Target.ClearComments
        Target.AddComment ("Comment 2")
        Exit Sub
    End If
    'etc
End Sub

This is very basic, but without knowing your requirements and cells of interest, I can't be more specific.

You might also, depending on you needs, elect to use Select Case instead of IFs

lenze
 

leonem

New Member
Joined
Apr 5, 2006
Messages
36
Is there anyway i can make the comment show without having to format the cell to "show comment"???
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Is there anyway i can make the comment show without having to format the cell to "show comment"???

I don't understand your question. You can hide or show the comments under Tools>Options. Is that what you mean?

Maybe this is what you mean. You can add the line
Code:
Target.Comment.Visible = True
So now you have
Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
    If Target.Count > 1 Then Exit Sub 
    If Target.Address <> "$C$4" Then Exit Sub 
    If Target > 100 Then 
        Target.ClearComments 
        Target.AddComment ("Comment 1") 
        Target.Comment.Visible = True
        Exit Sub 
    End If 
    If Target > 50 Then 
        Target.ClearComments 
        Target.AddComment ("Comment 2") 
        Target.Comment.Visible = True
         Exit Sub 
    End If 
    'etc 
End Sub

You will also need to write some script to make the comment go away
EDIT: You can use the Before_DoubleClick to remove the comment

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      Target.Comment.Visible = False
      Cancel = True
End Sub

HTH

lenze
 

Watch MrExcel Video

Forum statistics

Threads
1,114,041
Messages
5,545,687
Members
410,698
Latest member
Wloven
Top