View Single Post
  #10   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

Using .Formula instead of .Text shouldn't create any problems.
What happened when you tried it? <g

Alan wrote:
"Debra Dalgleish" wrote in message
...

The following code will add a comment to the cell that was changed:

'=========================
Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim oldtext As String
Dim newtext As String

With Target
On Error Resume Next
oldtext = .Comment.Text
If Err < 0 Then
.AddComment
End If
On Error GoTo 0
newtext = oldtext & " Changed to " & .Text & _
" by " & Application.UserName & " at " & Now & vbLf
With .Comment
.Text newtext
.Visible = True
.Shape.TextFrame.AutoSize = True
.Visible = True
End With
End With
End Sub
'============================



Another comment / question:

Wouldn't it be more useful to use the FORMULA property of the range
(cell), rather than the TEXT property on this line:

newtext = oldtext & " Changed to " & .Formula & _


Is there any downside to using the FORMULA property that I am not
foreseeing?

Alan.





--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html