Tank
Assumes you have the cells in Const My_Range unlocked and sheet protected with
password of "justme"(no quotes)
Private Sub Worksheet_Change(ByVal Target As Range)
Const My_Range As String = "A1:A10"
' or "A1, A3, A6, A8, A10"
If Not Intersect(Target, Me.Range(My_Range)) Is Nothing Then
ActiveSheet.Unprotect Password:="justme"
Target.Interior.ColorIndex = 0
On Error Resume Next
Dim curComment As String
curComment = ""
curComment = Target.Comment.Text
If curComment < "" Then curComment = curComment & Chr(10)
Target.AddComment
Target.Comment.Text Text:=curComment & _
ActiveWorkbook.Application.UserName & _
Chr(10) & " Rev. " & Format(Date, "yyyy-mm-dd ") & _
Format(Time, "hh:mm")
ActiveCell.Comment.Visible = False
ActiveSheet.Protect Password:="justme"
End If
'comment perhaps should be resized
End Sub
Gord
On Sun, 7 Jan 2007 21:22:00 -0800, tankerman
wrote:
I have a couple of questions maybe you can address for me
First -- I am having trouble figuring our how to have the comment in just
certain cells, I have tried several differnt ways but I am stuck and unable
to exclude cells.
Second -- I tried to protect my sheet but when I do the coding wont work on
inserting the comments, I need an accurate list of the ones editing the
sheets and only on specific cells.
If you could help me with this I would certainly appreciate the help.
Tankerman
"Gord Dibben" wrote:
Tank
Try username instead.
Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 0
On Error Resume Next
Dim curComment As String
curComment = ""
curComment = Target.Comment.Text
If curComment < "" Then curComment = curComment & Chr(10)
Target.AddComment
Target.Comment.Text Text:=curComment & _
ActiveWorkbook.Application.UserName & _
Chr(10) & " Rev. " & Format(Date, "yyyy-mm-dd ") & _
Format(Time, "hh:mm")
ActiveCell.Comment.Visible = False
'comment perhaps should be resized
End Sub
Gord Dibben MS Excel MVP
On Wed, 3 Jan 2007 11:44:00 -0800, tankerman
wrote:
I have a spreadsheet that is on a shared drive and several people update this
sheet daily, I had found this VB that was posted by someone back in August of
this year and it works almost perfect except for one small item, HOW can I
track who is updating the cells, when the person puts the sheet on the shared
drive or emailed to one of the others and a cell is updated the name that
appears in the comment is the one who put the sheet on the drive and not the
person updating it. Is there a way to have the one who is updating the cell
to have their name add to the others who had update the cell earlier.
Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 0
On Error Resume Next
Dim curComment As String
curComment = ""
curComment = Target.Comment.Text
If curComment < "" Then curComment = curComment & Chr(10)
Target.AddComment
Target.Comment.Text Text:=curComment & _
ActiveWorkbook.BuiltinDocumentProperties("Author") & _
Chr(10) & " Rev. " & Format(Date, "yyyy-mm-dd ") & _
Format(Time, "hh:mm")
ActiveCell.Comment.Visible = False
'comment perhaps should be resized
End Sub