Hello,
I have two vba codes one for time stamping the other to lock cells after data input. How would I go about combining the two in the same worksheet?
"Lock cells on data input"
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo justenditall
Application.EnableEvents = False
If Not Intersect(Target, Range("A1:Z300")) Is Nothing Then
If Target.Value <> "" Then
ActiveSheet.Unprotect Password:="thepassword"
Target.Locked = True
End If
End If
ActiveSheet.Protect Password:="thepassword"
justenditall:
Application.EnableEvents = True
End Sub
"Time stamp"
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("e2:e10500"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 3).ClearContents
Else
With .Offset(0, 3)
.NumberFormat = "hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("i2:i10500"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 2).ClearContents
Else
With .Offset(0, 2)
.NumberFormat = "hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub
I will greatly appreciate all the help given. Thanks
Bookmarks