Parts of Excel turn white or gray when you run VBA code in Excel 2013
บทความ
นำไปใช้กับ:
Excel 2013
Symptoms
When you run Microsoft Visual Basic for Applications (VBA) code in Microsoft Excel 2013, portions of Excel may appear white or gray, depending on your Office Theme. It stays blank until the code completes. This issue may occur if the VBA code performs one or more of the following actions in a macro that runs long enough for the user to see the results before the macro completes:
Repeatedly select cells
Insert sheets
Update or opens task panes
Add a workbook
Cause
This issue is caused by the changes that are made in Microsoft Office 2013 to optimize the new graphics engine.
Workaround
Use ScreenUpdatingto disable the screen updates of Excel so you don't see the changes while they're disabled. This also may improve your macro performance.
If you need to see the screen changes, insert a DoEvents command after the line in the code that causes the screen to appear white. Using DoEvents sparingly helps maintain macro performance.
VB
Workbooks.Add
DoEvents
Status
This limitation is a known limitation in Excel 2013.
หมายเหตุ
For all versions of Excel, a similar effect can occur in long running macros when Windows turns the application white and marks it not responding. This occurs because Excel is not responding to Windows while the macro is running. DoEvents will also assist in this scenario by allowing Excel to respond to Windows and allow the application screen to recover.