I have a VBA code that does 2 things, firstly it stops copy and pasting over validated cells and secondly it automatically moves lines from one tab to another, for some reason when I make the workbook a shared one, the copy and paste part of the code no longer works
Any help gratefully received.
Thanks
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xValue As String
Dim xCheck1 As String
Dim xCheck2 As String
If Target.Count = 1 Then
Application.EnableEvents = False
xValue = Target.Value
On Error Resume Next
xCheck1 = Target.Validation.InCellDropdown
On Error GoTo 0
Application.Undo
On Error Resume Next
xCheck2 = Target.Validation.InCellDropdown
On Error GoTo 0
If xCheck1 = xCheck2 Then
Target = xValue
Else
MsgBox "No pasting allowed!"
End If
Application.EnableEvents = True
End If
If Intersect(Target, Range("M:M")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.ScreenUpdating = False 'moved to prevent exiting sub with screenupdating turned off
Application.EnableEvents = False
If Target.Value = "Patient Files" Then
Target.EntireRow.Copy Worksheets("Patient Files").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Target.EntireRow.Delete
End If
endit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Any help gratefully received.
Thanks