Monday, August 10, 2020

Excel VBA How to change value of a cell using Scroll Bar

Private Sub ScrollBar1_Change()
    Application.EnableEvents = False
    ScrollBar1.Min = -100
    ScrollBar1.Max = 100
    ScrollBar1.SmallChange = 1
    ScrollBar1.LargeChange = 5
    ShtGraph1.Range("A5").Value = ScrollBar1.Value * 0.01
    Application.EnableEvents = True
End Sub

Private Sub ScrollBar1_Scroll()
    Application.EnableEvents = False
    ScrollBar1.Min = -100
    ScrollBar1.Max = 100
    ScrollBar1.SmallChange = 1
    ScrollBar1.LargeChange = 5
    ShtGraph1.Range("A5").Value = ScrollBar1.Value * 0.01
    Application.EnableEvents = True
End Sub

NOTE: The A5 cell should be in percentage format to see change of percentage value.

No comments:

Post a Comment

Hot Topics