XL97: Min Can Exceed Max on ScrollBar or SpinButton Control

Last reviewed: March 13, 1998
Article ID: Q161816
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

You can set the Min property to a value that is greater than the value for the Max property for the ScrollBar and SpinButton ActiveX controls.

STATUS

This behavior is by design of Microsoft Excel 97.

MORE INFORMATION

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

When you set the Min property to a value that is greater than the value for the Max property, the default behavior of the control is reversed. When this behavior occurs, clicking the arrow that points upward on a SpinButton control decreases the value of the SpinButton instead of increasing the value. The following example illustrates the behavior:

  1. Close and save any open workbooks, and then create a new workbook.

  2. Start the Visual Basic Editor (press ALT+F11).

  3. If the Properties Window is not visible, click Properties on the View menu (or press F4).

  4. On the Insert menu, click UserForm.

  5. Draw a Label control on the UserForm.

  6. Draw a SpinButton control on the UserForm.

  7. Activate the Properties window (press F4).

  8. Change the following properties for the SpinButton control to the following values.

           Property      Value
           ---------------------------------------
           Orientation   0 - fmOrientationVertical
           Min           100
           Max           50
           Value         75
    
    

  9. Double-click the SpinButton to display the Code window for the UserForm.

  10. In the module, type the following code for the SpinButton1 Change event:

    Private Sub SpinButton1_Change()

               'Set the Caption of the label to the value of the SpinButton.
               Label1.Caption = SpinButton1.Value
       
           End Sub
    
    

  11. Run the UserForm.

When you click the upward pointing arrow on the SpinButton, the value in the label is decreased. This behavior is the result of setting the Min property of the SpinButton to a value that is greater than the value for the Max property.

  1. Close the UserForm.

NOTE: This behavior also occurs in a ScrollBar or a SpinButton control is that you place on a worksheet.

REFERENCES

For more information about SpinButtons, click the Office Assistant, type "spinbutton", click Search, and then click to view "SpinButton Control".

For more information about Scrollbar Controls, click the Office Assistant, type "scrollbar", click Search, and then click to view "ScrollBar Control".

For more information about adding ActiveX Controls to a Worksheet, click the Office Assistant, type "toolbox", click Search, and then click to view "About buttons, check boxes, or other controls to a worksheet".

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Excel Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office
               Program or Component


Additional query words: XL97 scroll bar spin button
Keywords : kbcode kbprg kbualink97 kbui xlvbahowto xlvbainfo xlui
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto


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