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

  1. Private Sub SpinButton1_Change()
  2. TextBox1.Text = SpinButton1.Value
  3. End Sub
  4. Private Sub UserForm_Initialize()
  5. SpinButton1.Min = 1
  6. SpinButton1.Max = 100
  7. SpinButton1.SmallChange = 1
  8. End Sub

The above code increases the value of the text box by 1 as specified in the form_initialize event

excel vba spin button control

excel vba spin button control

 

You can find similar Excel Questions and Answer hereunder

1) Here an explanation about buttons in VBA

2) Here an explanation about frames and how to control frames in Excel VBA

3) Here an explanation about combo boxes and interfacing with your user in Excel VBA

4) Here an explanation about label controls in the various forms and controls using VBA

5) What are ActiveX controls in VBA. Here some good explanations

6) Here an explanation about list box and how to control list boxes in Excel VBA

7) Here an explanation about text box and how to control text boxes in Excel VBA

8) How to control forms in Excel VBA

9) Here an explanation about checkbox and how to control checkboxes in Excel VBA

10) Here an explanation about the options in button control in Excel VBA

 

Here the previous and next chapter