I have some code that runs well but when added to the other code it causes problems. Some of the issues are preventing other batches of code from running, & type mismatch. I have commented out in the sample, the problem codes. The worksheet has Option Explicit as the first line of code, & the problem code is begins with Private Sub Worksheet_Change (ByVal Target As Range). The code below does not run when the problem codes are not commented out. This line of code does not run at all, Prevents Unauthorized word entry.
Code
'This code prevents modification or deletion of cells in the range below.
'Does not run when If Target.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub runs (top of code)
'Does not run when 'Reminds the user to enter the carryover name into the current FY listing is activated (3rd batch of code commented out)
If Intersect(Target, Range("A2:T3,A21:C23,B11:T12,A18:B18,B32:M50,C18:F18,D21:F21,D23:F24,E20:F20,F22,D4:D17,D21,D23:F24,E20:F20:F24,D21:F21,F18,F20:F22,G18:F18,G18:J18,K18:M19,B63:M81,E87:P90,N4:N10,N13:N17,AI2:AJ3,AI4:AI10,AI13:AI17,AW1")) Is Nothing Then Exit Sub
On Error GoTo ExitPoint
Application.EnableEvents = False
If Not IsDate(Target(1)) Then
Application.Undo
'Informs user that the cell that they clicked is locked.
Application.Speech.Speak "You can't delete or modify cell contents in this range. It is locked.", SpeakAsync:=True
Application.Wait (Now + TimeValue("00:00:01"))
MsgBox " You can't delete or modify cell contents in this range " _
, vbCritical, "Vocational Services - Career Link " & ActiveSheet.Name
End If
ExitPoint:
Application.EnableEvents = True
End Sub
The type mismatch code is commented in the sample, the problem codes are also commented. I can't figure out what is wrong, because the codes do run separately. I believe that there is some code syntax or something that I am not aware of.
Display More