none
Coding for Scroll Bar Range ( VBA Macro) RRS feed

  • Question

  • Hello

    I'm Rio from Indonesia

    I want to know VBA Macro code for scroll bar range

    Min range is week 37

    Max range is week 30

    So if we scroll the scroll bar, the value will change between week 37 until week 30 for the next year

    After week 52, it will be change to 1,2, and so on until 30

    Thank you

    Friday, February 3, 2017 3:38 AM

Answers

  • Hi,
    I think you can get result you want after you deal the value.
    e.g.

    Sub SetScrollBarRange()
    ScrollBar1.Min = -15
    ScrollBar1.Max = 30
    End Sub
    
    Private Sub ScrollBar1_Change()
    Dim val As Integer, sval As Integer
    val = ScrollBar1.Value
    If val <= 0 Then
    sval = val + 52
    Else
    sval = val
    End If
    Label1.Caption = "Week:" & sval
    End Sub
    
    Hope that can help you

    • Marked as answer by riok58 Tuesday, February 14, 2017 7:42 AM
    Monday, February 6, 2017 8:57 AM

All replies

  • Hello

    I'm Rio from Indonesia

    I want to know VBA Macro code for scroll bar range

    Min range is week 37

    Max range is week 30

    So if we scroll the scroll bar, the value will change between week 37 until week 30 for the next year

    Thank you

    Thursday, February 2, 2017 9:51 AM
  • Hi friend,

    This forum is for Visual Studio IDE, and your issue is more related to office development, I will it to corresponding forum for you to get a professional answer.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 3, 2017 3:29 AM
  • Hi,
    I think you can get result you want after you deal the value.
    e.g.

    Sub SetScrollBarRange()
    ScrollBar1.Min = -15
    ScrollBar1.Max = 30
    End Sub
    
    Private Sub ScrollBar1_Change()
    Dim val As Integer, sval As Integer
    val = ScrollBar1.Value
    If val <= 0 Then
    sval = val + 52
    Else
    sval = val
    End If
    Label1.Caption = "Week:" & sval
    End Sub
    
    Hope that can help you

    • Marked as answer by riok58 Tuesday, February 14, 2017 7:42 AM
    Monday, February 6, 2017 8:57 AM
  • Thank you for your help

    riok58

    Tuesday, February 21, 2017 2:49 AM