Excel: Clumsy VBA code slows down Excel


Hi, I've had some 25 of these kinds of IF-statements, and the worksheet has worked quickly:


Private Sub Worksheet_Change(ByVal Target As Range)
.
.
.
If Not Intersect(Target, Range("T82:AA457")) Is Nothing And ActiveSheet.Range("V80").Value = "-" Then
Application.EnableEvents = False
ActiveSheet.Range("T82:AA457").Value = ""
Application.EnableEvents = True
End If
However, I now added 25 other IFs, like this:

If Intersect(Target, Range("V80")) Is Nothing And ActiveSheet.Range("V80").Value = "-" Then
Application.EnableEvents = False
ActiveSheet.Range("T82:AA457").Value = ""
Application.EnableEvents = True
End If
As a result, whenever a cell is changed (any cell, not just the ones determined as the target ranges), Excel "thinks" for some five seconds and the mouse cursor indicates processing before the new cell value is displayed. Can someone help me?


This question generated 16 answers. To proceed to the answers, click here.

This thread is current as of September 26, 2014.


For more resources for Microsoft Excel