Excel Crashing after Worksheet_Change code

dreid1011

Well-known Member
Joined
Jun 4, 2015
Messages
3,633
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
It seems to be this:
VBA Code:
Application.ScreenUpdating
that is causing the issue. I have not ever seen this happen before.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top