# Microsoft Knowledge Base

## XL5: Changing State of Control Is Not Recorded

Last reviewed: March 27, 1997 Article ID: Q110501
5.00 7.00 | 5.00
    WINDOWS     MACINTOSH
kbusage The information in this article applies to:

- Microsoft Excel for Windows, version 5.0
- Microsoft Excel for the Macintosh, version 5.0
- Microsoft Excel for Windows 95, version 7.0

## SYMPTOMS

In Microsoft Excel, if you run the Macro Recorder and change the state of a control either on a worksheet or in a custom dialog box by selecting the control, this change is not recorded in your macro.

## CAUSE

This behavior is by design because you do not always want to record the change of the state of a control when you are recording a macro. For example, you may want to record an event macro that will perform an action regardless of the value of the control.

## WORKAROUND

To change the state of a control on a worksheet or in a custom dialog box, use either of the procedures below.

### Set Initial State of Control

To set the initial state of a button or check box control, do the following:

1. Select the control and choose Object from the Format menu.

2. Select the Control tab, and under Value, select the value you want the control to have.

### Change State of Control Within a Macro

To change the state of a control within a macro, use a command to change the Value property of the control. The available values for each control vary with the control. For information about the Value properties of each control, choose the Search button in the Visual Basic Reference and type the following:

       Value Property

## MORE INFORMATION

If you have assigned a procedure to the selection of a control, the procedure is recorded when you select that control while the macro recorder is running.

For example, if you assign the procedure Check_Box_Selected to a check box on your worksheet, the following code is written when you run the Macro Recorder and select the check box

       Application.Run Macro:="Book1!Check_Box_Selected"

(where BOOK1 is the name of the workbook containing the procedure that Check_Box_Selected). Use the Assign Macro command on the Tools menu to assign a macro to the selected control.

## REFERENCES

"Visual Basic User's Guide," pages 219-239

For more Tips For Working With Graphic Objects or Information On Controls, choose the Search button in Help and type:

       controls

> KBCategory: kbusage
> KBSubcategory:

> Additional reference words: 5.00 7.00
> Keywords : kbusage
> Version : 5.00 7.00 | 5.00
> Platform : MACINTOSH 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
©1997 Microsoft Corporation. All rights reserved. Legal Notices.