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



The information in this article applies to:

  • Microsoft Excel 2000

This article was previously published under Q213303

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.

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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: 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.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbhowto kbProgramming KB213303