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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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