Excel Crashing after Worksheet_Change code

dreid1011

Well-known Member
Joined
Jun 4, 2015
Messages
3,085
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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