View Full Version : ScrollBar value * call Macro

05-28-2009, 05:22 AM
Is it possible to let a scroll bar determine how many times a macro must repeat it self?

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

The macro is simple...

Sub Macro3()
Selection.Insert Shift:=xlToRight
End Sub

Thank you

05-28-2009, 08:35 AM
I don't follow the logic of the code. Why would you want to do this anyway?

05-28-2009, 08:56 AM
Not sure of your purpose either, but you used a text box change event, but talk about the scroll bar:dunno

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

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


05-29-2009, 03:53 AM
Someone else on the forum asked regarding this I am trying to help.

Thank you for the help.