Spin Button's What can they do?
a spinbutton just increments or decrements its value. You use this value as
you wish
create a blank userform in a new workbook and put a spinbutton on it.
(spinbutton1) and a textbox on it (textbox1)
put it code like this
Private Sub SpinButton1_SpinDown()
Textbox1.Text = SpinButton1.Value
End Sub
Private Sub SpinButton1_SpinUp()
Textbox1.Text = SpinButton1.Value
End Sub
The spinbutton has max and min values. Assume you wanted to walk up and
down in column A from A5 to A15
Private Sub Userform_Initialize()
SpinButton1.Max = 15
SpinButton1.Min = 5
End sub
Private Sub SpinButton1_SpinDown()
Textbox1.Text = worksheets("Sheet1").Cells(SpinButton1.Value,"A"). Value
End Sub
Private Sub SpinButton1_SpinUp()
Textbox1.Text = worksheets("Sheet1").Cells(SpinButton1.Value,"A"). Value
End Sub
--
Regards,
Tom Ogilvy
"Corey" wrote in message
...
I have populated several Textboxes by a listbox selection, ALL duplicate
entries have been removed
from the listbox.
The textbox shows data in the same row as the selected Listbox.value.
But as there may be more than 1 matching value to the listbox(not
displayed as duplicates are
removed),
what does a SPIN BUTTON do ?
If i place it next to a Textbox, can i set it to Scroll through the other
records ?
I have NEVER used a Spin Button and can onlu assume it could do this.
How do i set it to this, if it can do this?
The code i use to populate the textboxes is he
Private Sub ListBox2_Click()
Application.ScreenUpdating = False
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook.Worksheets("Data")
.Select
For myrow = 1 To LastCell
If .Cells(myrow, 1) < "" Then
If .Cells(myrow, 1).Offset(0, 59).Value = ListBox2.Value Then
TextBox1.Value = "A " & Cells(myrow, 1)
TextBox2.Value = Cells(myrow, 43)
TextBox3.Value = Cells(myrow, 19)
TextBox4.Value = Cells(myrow, 20)
End If
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Corey....
|