Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: How to a Make Spinner with a Minimum Value Less Than Zero


View products that this article applies to.

This article was previously published under Q213303

↑ Back to the top


Summary

In Microsoft Excel, the spinner control that is on the Forms toolbar has a minimum value of zero.

The Microsoft Excel Visual Basic for Applications macro example in this article demonstrates how you can use a spinner control that appears to allow negative numbers.

↑ Back to the top


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 professionals 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 a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS 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. Start Excel, and then create a new workbook.
  2. On the View menu, point to Toolbars, and then click to select the Forms check box (if it is not already checked).
  3. On the Forms toolbar, click the Spinner control.
  4. Click Cell A1 to place the spinner control next to cell A1 on your worksheet.
  5. Double-click the spinner control to display the Format Control dialog box.
  6. On the Control tab, type 0 in the Minimum value box, type 20 in the Maximum value box, and then 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).
  7. Right-click the spinner control, and then click Assign Macro on the shortcut menu.
  8. In the Assign Macro dialog box, click New.
  9. Type the following code in the module sheet:
    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).
  10. Press ALT+F11 to return to Excel.
  11. Select cell A1.
  12. Test the spinner control by clicking it. You see values in cell A1 that range between -10 and 10.

↑ Back to the top


Keywords: KB213303, kbprogramming, kbhowto, kbdtacode

↑ Back to the top

Article Info
Article ID : 213303
Revision : 8
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 334