View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default unmodifiable comment macro

Will this work for you?
'Summary: Place this code in the Worksheet_Change() event procedure
' Every time a cell's value is changed the date, time , old value,
' new value, and the user are recorded in a comment.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim NewText As String
Dim NewVal As Variant
Dim OldText As String
Dim OldVal As Variant

Application.EnableEvents = False
NewVal = Target.Value
Application.Undo
OldVal = ActiveCell.Value
ActiveCell = NewVal
Application.EnableEvents = True

NewText = "On " & Now() & " cell changed from " & OldVal _
& " to " & NewVal & " by " & Environ("UserName")

If ActiveCell.Comment Is Nothing Then
ActiveCell.AddComment
End If

With ActiveCell.Comment
..Shape.TextFrame.AutoSize = True
OldText = .Text & vbLf
..Text Text:=OldText & NewText
End With

End Sub

Also, see this:
http://www.contextures.com/xlcomments03.html#Plain


HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Adam at Star Packaging" wrote:

I am new to the macro world and need some help.

I am trying to set a macro that will place a comment. The information in the
comment should be:

User name. Datestamp (fixed to when macro was applied).

The comment should not be modifiable.

Is this possible?


(The object is to have this macro act as a "signature" for certain users
showing that they have "signed off" on information in specific cells.
Non-legal, intra-office use only.)

If there is an easier way than the macro suggestion above, I am open to
suggestions.

Thank you very much.