How would two vba codes work together in excel?
I am using below mentioned two vba codes. They work fine if used seperately but don't work if i put them together in the same sheet1 module.
I don't know much about it and doing this by searching on google. Please help what should i do.
Following are the codes:
Code1: FOR AUTOMATIC DATE AND TIME IN A CELL
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Written by Barrie Davidson
If Target.Column = 1 Then
Target.Offset(0, 1).Value = Now()
End If
End Sub
Code 2: FOR LOCKING CELLS AFTER DATA IS ENTERED
Private Sub Worksheet_Change(ByVal Target As Range)
If Me.ProtectContents Then
Me.Unprotect
Target.Locked = True
Me.Protect
End If
End Sub
WHEN PUT TOGETHER GOES LIKE THIS:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Written by Barrie Davidson
If Target.Column = 1 Then
Target.Offset(0, 1).Value = Now()
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Me.ProtectContents Then
Me.Unprotect
Target.Locked = True
Me.Protect
End If
End Sub
