By murdikayasa on Friday, 10 August 2018
Posted in Excel
Replies 0
Likes 0
Views 2.4K
Votes 0
Hi all, the code is working fine but i does not work when the worksheet is protected. although I have unprotected the column the certain column for the timestamp is. i am attaching the error message pop up. please help [attachment][/attachment] [attachment][/attachment]


Private Sub Worksheet_Change(ByVal Target As Range)
Call Micro1(Target)
Call Micro2(Target)
Call Micro3(Target)
End Sub

Private Sub Micro1(ByVal Target As Range)
If Target.Column = 1 Then
Target.Offset(0, 1).Select
ElseIf Target.Column = 2 Then
Target.Offset(1, -1).Select
End If
End Sub

Private Sub Micro2(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("A:A"), Target)
xOffsetColumn = 2
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, 2).Value = Now
Rng.Offset(0, 2).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, 2).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub

Private Sub Micro3(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("H:H"), Target)
xOffsetColumn = 6
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, 2).Value = Now
Rng.Offset(0, 2).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, 2).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
View Full Post