Vba spin button control in Excel
The spinbutton is a type of button that is used to increase or decrease a numerical value in a control by certain amount.
The increment or decrement value is predefined.
This control is used in conjunction with some other control to increase/decrease value.
The textbox is generally used with this control.
The important properties of the spin button control are discussed below
1.SmallChange
This property is used to specify the increment amount of the spin button control.
A negative value will cause the control to decrease the value.
This can also be set to float or decimal value.
2.Min Property
This property is used to set the minimum value of the spin button.
3.Max property
This property is used to set the maximum value.
The following code snippet shows the usage of spin button
- Private Sub SpinButton1_Change()
- TextBox1.Text = SpinButton1.Value
- End Sub
- Private Sub UserForm_Initialize()
- SpinButton1.Min = 1
- SpinButton1.Max = 100
- SpinButton1.SmallChange = 1
- End Sub
The above code increases the value of the text box by 1 as specified in the form_initialize event