Need Help...
I got runtime error 1004. Application defined or object defined error.
In excel sheet, Column H,I,J is locked and protected.
I want to capture the user name, date and week in column H,I,J when someone update the cell in column G.
below is the code. (It's work when sheet is not protected/remove the line ActiveSheet.Unprotect = "HullPU")
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect = "HullPU"
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("G6:G3000")) Is Nothing Then 'change your range on this line"
If Target.Value = 30 Then
Target.Offset(0, 1).Value = UserName
Target.Offset(0, 2).Value = Date
Target.Offset(0, 3).Value = Mid(Year(Date), 3, 2) & "_" & ISOWeekNum(Date)
Else
Target.Offset(0, 2).Value = Target.Offset(0, 2).Value
End If
End If
ActiveSheet.Protect = "HullPU"
End Sub
I got runtime error 1004. Application defined or object defined error.
In excel sheet, Column H,I,J is locked and protected.
I want to capture the user name, date and week in column H,I,J when someone update the cell in column G.
below is the code. (It's work when sheet is not protected/remove the line ActiveSheet.Unprotect = "HullPU")
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect = "HullPU"
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("G6:G3000")) Is Nothing Then 'change your range on this line"
If Target.Value = 30 Then
Target.Offset(0, 1).Value = UserName
Target.Offset(0, 2).Value = Date
Target.Offset(0, 3).Value = Mid(Year(Date), 3, 2) & "_" & ISOWeekNum(Date)
Else
Target.Offset(0, 2).Value = Target.Offset(0, 2).Value
End If
End If
ActiveSheet.Protect = "HullPU"
End Sub