View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Listbox 01 -- 50 in UserForm

In article ,
Dave Peterson wrote:

Sometimes, clicking 50 times on a spinner can be too much to ask the user to
do.


Keeps them numbers low... encourages workarounds... <g

However, you can use a Textbox to make it convenient to enter values,
too:

Private Sub ScrollBar1_Change()
If Not bDontUpdate Then
On Error Resume Next
bDontUpdate = True
Me.TextBox1.Text = Format(Me.ScrollBar1.Value, "00")
bDontUpdate = False
End If
End Sub

Private Sub TextBox1_AfterUpdate()
If Not bDontUpdate Then
On Error Resume Next
bDontUpdate = True
With Me.TextBox1
If IsNumeric(.Value) Then _
If .Value = Me.ScrollBar1.Min Then _
If .Value <= Me.ScrollBar1.Max Then _
Me.ScrollBar1.Value = CLng(.Value)
.Value = Format(Me.ScrollBar1.Value, "00")
bDontUpdate = False
End With
End If
End Sub

Private Sub UserForm_Initialize()
bDontUpdate = False
With Me.ScrollBar1
.Max = 50
.Min = 1
.LargeChange = 10
.SmallChange = 1
.Value = 1
End With
End Sub