Scrollbar Control

The scrollbar uses the Change event and the Scroll event to assign the Value property of the scrollbar to cell B3. The maximum and minimum values of the scrollbar are set by the option buttons (this is discussed later):

Private Sub ScrollBar1_Change()

'Assign scrollbar value to B3

Range("B3").Value = ScrollBarl.Value

End Sub

The Change event procedure is triggered when the scrollbar value is changed by clicking the scroll arrows, by clicking above or below the scroll box (or to the left or right if it is aligned horizontally), or by dragging the scroll box. However, a small glitch occurs immediately after you change the option buttons. Dragging the scroll box does not trigger the Change event on the first attempt. Utilizing the Scroll event procedure solves this problem.

The Scroll event causes continuous updating as you drag the scrollbar, so you can see what figure you are producing as you drag, rather than after you have released the scrollbar. It might not be practical to use the Scroll event procedure in a very large worksheet in auto-recalculation mode because of the large number of recalculations it causes.

0 0

Post a comment