XL: How to Make Spinner Whose Minimum Value Is Less Than Zero

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

SUMMARY

In the products listed at the beginning of this article, the spinner control that is on the Forms toolbar has a minimum value of zero. This article includes a Microsoft Excel Visual Basic for Applications macro example that demonstrates how you can use a spinner control that appears to allow negative numbers.

MORE INFORMATION

Microsoft provides programming examples 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. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

In the following example, you create a spinner control that appears to have a minimum value of -10 and a maximum value of 10. The spinner control stores its result in cell A1.

  1. Create a new workbook.

  2. Right-click (or CONTROL-click) the toolbar area in Microsoft Excel. Click Forms on the menu to display the Forms toolbar.

  3. Click the spinner control on the Forms toolbar and draw the spinner control next to cell A1 on your worksheet.

  4. Double-click the spinner control to display the Format Object dialog box. Click the Control tab. Type a Minimum Value of "0" (without the quotation marks) and a Maximum Value of "20" (without the quotation marks), and click OK.

    NOTE: You set the Maximum to 20 because the difference between the minimum and the maximum values that you want to use is 20 (that is, 10-(-10)=20).

  5. Right-click (or CONTROL-click) the spinner control and click Assign Macro.

  6. Click New in the Assign Macro dialog box.

  7. Type the following macro in the module:

          Const Diff = 10
    

          Sub Spinner1_Change()
              Range("A1").Value = _
                  ActiveSheet.Spinners("Spinner 1").Value - Diff
          End Sub
    
       NOTE: The constant Diff is equal to the difference between 0 and the
       minimum value that you want to use (that is, 0-(-10) = 10).
    
    

  8. Activate the worksheet that contains the spinner control. Select cell A1. Test the spinner control by clicking it. You should see values in cell A1 that range between -10 and 10.


Additional query words: 5.00 5.00a 5.00c 7.00 8.00 XL97 XL98 XL7 XL5
Increment Minimum
Keywords : kbcode kbprg PgmHowto
Version : WINDOWS:5.0,5.0c,7.0,97; MACINTOSH:5.0,5.0a,98
Platform : MACINTOSH 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: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.