User name , date and time

R

Rod

Hi all,

Merry christmas .

I need to insert a comment of user name, date and time automatically when a
cell is changed or in next cell user name , date and time should come
automatically.
date should not be changed to current date while reopen.

thank you.
 
G

Gary''s Student

Merry Christmas to you as well

Insert this macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
n = ActiveSheet.UsedRange.SpecialCells(xlComments).Count
If n = 0 Then
Else
Set r = ActiveSheet.UsedRange.SpecialCells(xlComments)
If Intersect(r, Target) Is Nothing Then
Else
Target.Comment.Delete
End If
End If
With Target
.AddComment
.Comment.Visible = False
.Comment.Text Text:=Now() & " " & Environ("username")
End With
End Sub

Whenever a cell is changed via user input, the date, time, and username are
recorded in a comment in the cell.

REMEMBER: the worksheet code area, not a standard module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top