dreid1011
Well-known Member
- Joined
- Jun 4, 2015
- Messages
- 3,614
- Office Version
- 365
- Platform
- Windows
I just wrote the following code for a user, and in the midst of testing, my copy of Excel began acting erratically each time I changed a value in a cell. The selection jumps quickly between the below adjacent cell once or twice and then sometimes crash to desktop. This behavior happens even if I comment out the entire working section of the code between disabling and enabling events. Thoughts?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo SetMeFree
Dim ws As Worksheet
Dim lRowA As Long, lRowC As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
Set ws = Worksheets("Complete")
lRowA = Range("A" & Rows.Count).End(xlUp).Row
lRowC = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
If Not Intersect(Target, Range("Q2:Q" & lRowA)) Is Nothing And Target.Count = 1 Then
If Range("Q" & Target.Row).Value = "Yes" Then
Range("A" & Target.Row & ":Q" & Target.Row).Copy
ws.Range("A" & lRowC).PasteSpecial xlPasteValues
Rows(Target.Row & ":" & Target.Row).Delete Shift:=xlUp
Application.CutCopyMode = False
End If
Else
GoTo SetMeFree
End If
SetMeFree:
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub