Macro Errors May Occur if an Object Is Currently SelectedLast reviewed: November 2, 1994Article ID: Q72137 |
SUMMARYAn error might be encountered in a macro if you attempt to manipulate the worksheet after selecting an object. A dialog box displays, stating that there is an error in the macro at the cell where the command tries to adjust the worksheet.
MORE INFORMATIONFor example, the following macro selects a button on a worksheet and then attempts to adjust the row heights of a selected range. The macro will generate an error at cell A3.
A1: =SELECT("button 1") A2: =FORMAT.SIZE(72,36,!C5) A3: =ROW.HEIGHT(0,"r15:r20") A4: =RETURN()However, if you place the command in A3 to run first, the macro will run correctly. Another workaround is to follow the Select command with a second Select command that selects any cell on the worksheet.
A1: =ROW.HEIGHT(0,"r15:r20") A2: =SELECT("button 1") A3: =FORMAT.SIZE(72,36,C5) A4: =RETURN() -or- A1: =SELECT("button 1") A2: =FORMAT.SIZE(72,36,C5) A3:= SELECT(!A1) A4: =ROW.HEIGHT(0,"R15:R20") A5: =RETURN()This error occurs because objects are on a different layer than the worksheet layer. Although the worksheet is the active document, the object layer is the active layer when the worksheet manipulation is attempted. Other commands may also cause macro errors if attempted when an object is the current selection. Some commands, such as the Formula command will work fine.
REFERENCES"Microsoft Excel Function Reference." Version 3.00, pages 210, 211.
|
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |