Consulting

Results 1 to 4 of 4

Thread: ScrollBar value * call Macro

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location

    ScrollBar value * call Macro

    Is it possible to let a scroll bar determine how many times a macro must repeat it self?

    [VBA]Private Sub TextBox1_Change()
    On Error GoTo Msg
    ScrollBar1 = TextBox1.Value
    Exit Sub
    Msg:
    MsgBox "Choose a number between 1-100"
    End Sub[/VBA]

    The macro is simple...

    [VBA]Sub Macro3()
    Selection.Insert Shift:=xlToRight
    End Sub[/VBA]

    Thank you

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I don't follow the logic of the code. Why would you want to do this anyway?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Not sure of your purpose either, but you used a text box change event, but talk about the scroll bar

    This is on theWorksheet code page of the attached WB and uses an ActiveX version of the scroll bar control on that WS


    [vba]
    Option Explicit
    Private Sub ScrollBar1_Change()
    Dim i As Long

    ScrollBar1.Max = 100
    ScrollBar1.Min = 1


    For i = 1 To ScrollBar1.Value
    Called (i)
    Next i


    End Sub
    Sub Called(i As Long)
    Debug.Print i
    End Sub
    [/vba]

    Paul

  4. #4
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    Someone else on the forum asked regarding this I am trying to help.

    Thank you for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •