try:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rInt As Range
Dim rCell As Range
Dim tCell As Range
Dim myTime As Date
Set rInt = Intersect(Target, Range("A:A"))
If Not rInt Is Nothing Then
'just in case you're doing this at midnight
myNow = Now
myDate = Int(myNow)
myTime = myNow - myDate
On Error GoTo errHandler 'only enable when finished debugging. (Speeds up)
Application.EnableEvents = False 'only enable when finished debugging.
For Each rCell In rInt
If Not IsError(Application.Match(rCell.Value, Sheets("Student Roster").Range("A:A"), 0)) Then
Set tCell = rCell.Offset(0, 1)
If IsEmpty(tCell) Then
tCell = myNow
tCell.NumberFormat = "mmm dd, yyyy hh:mm:ss AM/PM"
End If
Set tCell = rCell.Offset(0, 2)
If IsEmpty(tCell) Then
tCell = myDate
tCell.NumberFormat = "dddd mmm dd, yyyy"
End If
Set tCell = rCell.Offset(0, 3)
If IsEmpty(tCell) Then
tCell = myTime
tCell.NumberFormat = "hh:mm:ss AM/PM"
End If
Else 'not a match in student roster:
Application.EnableEvents = False 'must be present here if not elsewhere to prevent infinite looping.
rCell.ClearContents
Beep
End If
Next
'Else 'this Else line not needed, not a change in column A
End If
errHandler:
Application.EnableEvents = True
End Sub