Microsoft KB Archive/151324

= How to Make Spinner Whose Minimum Value Is Less Than Zero =

Article ID: 151324

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q151324





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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. 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.

 Create a new workbook. Right-click (or CONTROL-click) the toolbar area in Microsoft Excel. Click Forms on the menu to display the Forms toolbar. Click the spinner control on the Forms toolbar and draw the spinner control next to cell A1 on your worksheet. Double-click the spinner control to display the Format Object dialog box. Click the Control tab. Type a Minimum Value of 0 and a Maximum Value of 20, 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). Right-click (or CONTROL-click) the spinner control and click Assign Macro. Click New in the Assign Macro dialog box.</li>  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). </li> 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.</li></ol>

Additional query words: 5.00a 5.00c 8.00 XL97 XL98 XL7 XL5 Increment Minimum XL

Keywords: kbdtacode kbhowto kbprogramming KB151324

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.