Hello,
I am looking to create a macro which takes any input in columns A through D and stamps a username and a date in columns 7 and 8 respectively. Here is the code I currently have, and I can't figure out why it isn't working. Any assistance would be greatly appreciated.
Marc
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell As Range
Dim rChange As Range
On Error GoTo ErrHandler
Set rChange = Intersect(Target, Range("A:D"))
If Not rChange Is Nothing Then
Application.EnableEvents = False
For Each rCell In rChange
If rCell > "" Then
Cells(Target.Row, 7).Value = UserName()
Cells(Target.Row, 8).Value = Date & " " & Time()
Else
rCell.Offset(0, 1).Clear
End If
Next
End If
ExitHandler:
Set rCell = Nothing
Set rChange = Nothing
Application.EnableEvents = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
Public Function UserName()
UserName = Environ$("UserName")
End Function
Bookmarks