Worksheet Change - ScreenUpdating

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I`m using Worksheet_Change to put values in table. I set DisplayAlerts and ScreenUpdating to FALSE.
Code:
Application.DisplayAlerts = False
Application.ScreenUpdating = False


    If Target.Address = "$D$9" Then
        For g = 1 To rowdata_lr
               ......
        next g
    End if

Application.DisplayAlerts = TrueApplication.ScreenUpdating = True


But when code is running (after I select value from list in D9), I see like values are showing one-by one, and screen is refreshing.

Can somehow I eleminate this?
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Here's the thing. You're using Worksheet_Change, which is an event that is triggered every time a cell is changed.

What happens when you make a change to D9? It is then changing a bunch of other cells, and each one of those cells is also triggering the event. Part of that means disabling and reenabling screen updating, which means that each change results in a screen refresh.

Try this:

Code:
    If Target.Address = "$D$9" Then
        Application.DisplayAlerts = False
        Application.ScreenUpdating = False
        Application.EnableEvents = False

        For g = 1 To rowdata_lr
               ......
        next g

        Application.EnableEvents = True
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
    End If

That way, you are not only disabling updates only when the appropriate cell is triggered, you are also disabling events for the changes you're making yourself. Code should run much faster now, too.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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