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/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryserviceFor 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.
- Start Excel, and then create a new workbook.
- On the View menu, point to Toolbars, and then click to select the Forms check box (if it is not already checked).
- On the Forms toolbar, click the Spinner control.
- Click Cell A1 to place the spinner control next to cell A1 on your worksheet.
- Double-click the spinner control to display the Format Control dialog box.
- 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). - Right-click the spinner control, and then click Assign Macro on the shortcut menu.
- In the Assign Macro dialog box, click New.
- 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).
- Press ALT+F11 to return to Excel.
- Select cell A1.
- Test the spinner control by clicking it. You see values in cell A1 that range between -10 and 10.