I am current running the code below, to auto populate dates into column A when someone puts their initials into column B. If someone drags their initials to cover more then one block it is giving error 13. I am unsure how to fix this error. I am also trying to find a way to add into the code, that once the person the initials into column B, it locks the Row from A-G. So example Joe Smith, initials B2-B5, it auto dates A2-A5 and locks all rows from A2 to G5. If i can please get help adding that code, and fixing the error 13.
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("B:B").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "A").Value = Now
Else
Cells(Cell.Row, "A").Value = ""
End If
End If
Next Cell
Dim PreviousValue
Dim i As Long
Dim ws As Worksheet
Set ws = Sheets("log")
i = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
If Target.Value <> PreviousValue Then
With ws
.Range("A" & i).Value = Application.UserName
.Range("B" & i).Value = Target.Address
.Range("C" & i).Value = PreviousValue
.Range("D" & i).Value = Target.Value
.Range("E" & i).Value = Format(Now(), "dd/mm/yyyy")
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("B:B").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "A").Value = Now
Else
Cells(Cell.Row, "A").Value = ""
End If
End If
Next Cell
Dim PreviousValue
Dim i As Long
Dim ws As Worksheet
Set ws = Sheets("log")
i = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
If Target.Value <> PreviousValue Then
With ws
.Range("A" & i).Value = Application.UserName
.Range("B" & i).Value = Target.Address
.Range("C" & i).Value = PreviousValue
.Range("D" & i).Value = Target.Value
.Range("E" & i).Value = Format(Now(), "dd/mm/yyyy")
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub