XL: Code "Behind" Worksheet or Workbook May Not Work (213581)
The information in this article applies to:
- Microsoft Excel 2000
- Microsoft Excel 2002
This article was previously published under Q213581 For a Microsoft Excel 97 version of this article, see 157346.
For a Microsoft Excel 98 version of this article, see 182482.
SYMPTOMS
In Microsoft Excel, code that is contained "behind" a worksheet or
workbook may not work correctly.
CAUSE
This will occur if both of the following conditions are true:
- The code in question is contained inside an automatically-running subroutine, such as an Auto_Open or Auto_Close subroutine.
-and-
- The code is not contained in a Visual Basic module, but "behind" a worksheet or the workbook itself.
WORKAROUND
In order for automatically-running subroutines to work correctly in
Microsoft Excel, they must be contained within a Visual Basic module.
You must insert a Visual Basic module into the workbook and then place the code in the new module.
To insert a Visual Basic module:
- In the Project Explorer in the Visual Basic Editor, activate the workbook that contains the code in question.
- On the Insert menu, click Module.
After the new module is inserted, cut the code from its original location
and paste it into the Visual Basic module. Then, save the workbook.
Modification Type: | Major | Last Reviewed: | 10/8/2003 |
---|
Keywords: | kbpending kbprb kbProgramming KB213581 |
---|
|