View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] sbitaxi@gmail.com is offline
external usenet poster
 
Posts: 158
Default Inserting Comments with VBA

On Sep 24, 9:44*am, akemeny wrote:
Hi

I'm looking for a macro that will automatically enter the current date and a
note in the comments box when certain information is entered into specific
cells on my spreadsheets without deleting any old comments.

For example:

When V = unfavorable, automatic comment should enter:
* * * * - The current date (Blue and Bold)
* * * * - The note (standard font and color)
When V = favorable, automatic comment should enter:
* * * * - The current date (Blue and Bold
* * * * - The note (standard font and color)
Etc.

Is this possible??


Hello:

This will insert the comment, I can't get text formatting to work in a
comments field. There is probably a way, but this will at least start
you off.

Insert this into the Worksheet code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim MyCell As Range

MyString = Now
MyString2 = ": Unfavourable text"
MyString3 = ": Favourable text"


With Target
Select Case .Value
Case "favourable"
With .AddComment
.Text Now & MyString3
End With
Case "unfavourable"
With .AddComment
.Text Now & MyString2
End With
Case Else
'Do nothing
End Select
End With
End Sub