XL: Scrolling Through List Box on Worksheet Runs Attached Macro

Last reviewed: February 3, 1998
Article ID: Q133046
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

When you place a list box control on a worksheet and attach a macro to the list box, the attached macro is run every time you click the scroll bar.

This behavior may not be what you expect. For example, you may want the macro to be run only when a user selects a new item from the list box.

WORKAROUNDS

To work around this behavior, use either of the following methods.

Method 1: Adjust the Size of the List Box

You can adjust the size of the list box on the worksheet to display all of the items in the list at one time. This way, you will not have to use the scroll bar.

Method 2: Use a Drop-Down Box

You can use a drop-down box rather than a list box. The drop-down box will display the last chosen item from the list, but you can click on the drop- down arrow and scroll through the list with the drop-down scroll bar and the attached macro will not run until you select a new item from the list.

MORE INFORMATION

In Microsoft Excel, you can place controls, such as list boxes and drop- down boxes, on a worksheet. You can also attach macros to these controls; the macros should be run when you choose a new item from the list that is contained in the list box or drop-down box.

REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 11, "Controls and Dialog Boxes"

For more information about List Box controls, click the Search button in Help and type:

   List box button


Additional query words: 5.00 5.00a 5.00c 7.00 8.00 97 XL97 listbox
dropdown Mac
Keywords : kbprg PgmOthr
Version : WINDOWS:5.0,5.0c,7.0,97; MACINTOSH:5.0,5.0a,98
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


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: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.