XL: Worksheet May Be Activated When Method Is Applied

Last reviewed: March 27, 1997
Article ID: Q106463
5.00 5.00c 7.00 WINDOWS kbusage

The information in this article applies to:

  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0

SUMMARY

When you apply methods or change properties of a worksheet, the target worksheet may need to be activated before the macro can perform the requested action. If the worksheet is not already active, a brief flash will be noticeable on the screen when the sheet is activated.

WORKAROUND

To resolve the problem explained in this article, add the following line to the beginning of your Visual Basic for Applications macro:

   Application.ScreenUpdating = False

MORE INFORMATION

Some methods and properties that are applied to worksheets will cause the worksheet to be briefly activated.

Steps to Reproduce Behavior

  1. From the File menu, choose New, and then choose Workbook.

  2. From the Insert menu, choose Macro, and then choose Module.

  3. In the Visual Basic module, type the following text:

         Sub Protect_Sheet1()
    
            ActiveWorkbook.Sheets("Sheet1").Protect
         End Sub
    
    

  4. With the Visual Basic module active, choose Macro from the Tools menu. Select Protect_Sheet1 from the list and choose Run.

The following procedures will also briefly activate the worksheet:

   ActiveWorkbook.Sheets("Sheet1").Unprotect
   ActiveWorkbook.Sheets("Sheet1").Visible = True

Some methods or properties, such as the one in the following example, may activate the sheet and cause it to remain the active sheet:

   ActiveWorkbook.Sheets("Sheet1").Move


KBCategory: kbusage
KBSubcategory:

Additional reference words: 5.00 5.00c 7.00
Keywords : kbusage
Version : 5.00 5.00c 7.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 27, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.