Hi,
Thank you for having a look-see at my inquiry. I'm currently trying to create a Time and Motion Template and would need to have Columns A to F "locked" once data has been entered.
These are the current macros that I have:
Entering Date and Time for Columns A - C respectively
Then locking Cells A to F via macro:
Right now, the macro is working for Columns A, D - F. I can still delete the time/data for Columns B and C though Can anyone help me out please?
Thank you for having a look-see at my inquiry. I'm currently trying to create a Time and Motion Template and would need to have Columns A to F "locked" once data has been entered.
These are the current macros that I have:
Entering Date and Time for Columns A - C respectively
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Dim rng As Range
Set rng = Range("TimeStartEnd")
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, rng) Is Nothing Then
Application.EnableEvents = False
Cancel = True 'stop the edit mode
With Target
If .Value = "" Then
.Value = Time
.Offset(0, 1).Activate
End If
End With
End If
Application.EnableEvents = True
If Not Intersect(Target, Range("DateProcessed")) Is Nothing Then
Cancel = True
Target.Formula = Date
End If
End Sub
Then locking Cells A to F via macro:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A2:F600"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="MIS2017"
xRg.Locked = True
Target.Worksheet.Protect Password:="MIS2017"
End Sub
Right now, the macro is working for Columns A, D - F. I can still delete the time/data for Columns B and C though Can anyone help me out please?