Last Updated on January 11, 2023 by token
Inserting VBA Spin Button – SpinButton (ActiveX Control)
The next ActiveX control we will learn is the Spin button control. We will use it for navigation, and precisely move the rows of the sheet up and down. When you click the down arrow, the sheet view should move down. How can you insert the VBA Spin Button? Go into the tab Developer. From the Insert icon, choose Spin Button and drop it on your Excel SpreadSheet.
Programming VBA Spin Button – SpinButton (ActiveX Control)
Due to the fact that the button and all controls of our application are in Sheet1, we also program the knob button in the Sheet1 object in the VisualBasic Editor. Assign the following code to the button by selecting previously the SpinUp and SpinDown triggers :
Private Sub SpinButton1_SpinUp() ActiveWindow.SmallScroll up:=1 End Sub Private Sub SpinButton1_SpinDown() ActiveWindow.SmallScroll down:=1 End Sub
The arrows on the button should work properly. A single click on the top arrow will move the sheet view up. The program will work the opposite when you click the bottom arrow. The code of our program looks like this: