The code below created a new line below when a cell in column F was changed (a dropdown menu). I'm certain it was working perfectly but now it isn't.
Can someone anyone see a problem with the code, please?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("F:F")) Is Nothing Then
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
ActiveSheet.Protect AllowDeletingRows:=True
On Error GoTo 0
End If
Application.EnableEvents = True
End Sub
Can someone anyone see a problem with the code, please?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("F:F")) Is Nothing Then
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
ActiveSheet.Protect AllowDeletingRows:=True
On Error GoTo 0
End If
Application.EnableEvents = True
End Sub