تفضل اخى الكريم
هذا الكود من ابداعات استاذنا الكبير ياسر خليل أبو البراء,له منا كل الحب والإحترام وجزاه الله عنا خير الجزاء وبارك الله فيه
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo t_time
If Target.Column = 2 And IsEmpty(Cells(Target.Row, 12)) Then
Application.EnableEvents = False
Cells(Target.Row, 12).Value = Date
Cells(Target.Row, 3).Value = Time
If Application.WorksheetFunction.CountIf(Range("L2:L500"), Cells(Target.Row, 12).Value) > 1 And Application.WorksheetFunction.CountIf(Range("B2:B500"), Cells(Target.Row, 2).Value) > 1 Then
Cells(Target.Row, 12).Value = ""
Cells(Target.Row, 3).Value = ""
Target.Value = ""
GoTo t_time
End If
t_time:
Application.EnableEvents = True
Application.ScreenUpdating = False
End If
Range("l:l").EntireColumn.AutoFit
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Target.Row > 2 Then
If Target.Column = 5 Or Target.Column = 8 Or Target.Column = 10 Then
If Cells(Target.Row, 2) = "" Or Application.WorksheetFunction.CountIf(Range("B2:B500"), Cells(Target.Row, 2).Value) > 1 Then Exit Sub
Target.Value = Now()
End If
End If
If Target.Column = 10 And Target.Row > 2 Then
Target = Format(Time, "hh:mm AM/PM")
End If
End Sub