I created a user entry form, that takes data in a table and displays that as a listbox in a VBA form. I've two toggle buttons, that cycle through the data. I've textboxes/combo boxes displaying that data on the form.
I am having trouble making the form update the data. I managed to get the first column to update when data is changed in the form, but I can't get anything else working. So mainly the code in the cmdUpdate_Click
sub.
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdRefresh_Click()
Dim x As Integer
For x = 0 To Me.lstMyData.ListCount - 1
If Me.lstMyData.Selected(x) Then Me.lstMyData.Selected(x) = False
Next x
End Sub
Private Sub ComboBox1_DropButtonClick()
microParaNameButt Me.ComboBox1
End Sub
'Private Sub ComboBox1_Change()
' microParaName Me.ComboBox1
'End Sub
Private Sub lstMyData_Click()
Dim i As Integer
i = Me.lstMyData.ListIndex
Me.lstMyData.Selected(i) = True
Me.TextBox1.Value = Me.lstMyData.Column(0, i)
Me.ComboBox1.Value = Me.lstMyData.Column(0, i)
Me.TextBox2.Value = Me.lstMyData.Column(1, i)
Me.ComboBox2.Value = Me.lstMyData.Column(1, i)
Me.TextBox3.Value = Me.lstMyData.Column(2, i)
Me.ComboBox3.Value = Me.lstMyData.Column(2, i)
Me.TextBox4.Value = Me.lstMyData.Column(3, i)
Me.ComboBox4.Value = Me.lstMyData.Column(3, i)
Me.TextBox5.Value = Me.lstMyData.Column(4, i)
Me.ComboBox5.Value = Me.lstMyData.Column(4, i)
Me.TextBox6.Value = Me.lstMyData.Column(5, i)
Me.ComboBox6.Value = Me.lstMyData.Column(5, i)
Me.TextBox7.Value = Me.lstMyData.Column(6, i)
Me.ComboBox7.Value = Me.lstMyData.Column(6, i)
Me.TextBox8.Value = Me.lstMyData.Column(7, i)
Me.ComboBox8.Value = Me.lstMyData.Column(7, i)
Me.TextBox9.Value = Me.lstMyData.Column(8, i)
Me.ComboBox9.Value = Me.lstMyData.Column(8, i)
Me.TextBox10.Value = Me.lstMyData.Column(9, i)
Me.ComboBox10.Value = Me.lstMyData.Column(9, i)
End Sub
Private Sub ToggleButton1_Click()
Dim i As Integer
i = Me.lstMyData.ListIndex
Me.lstMyData.Selected(i) = True
Me.TextBox1.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox1.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox2.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox2.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox3.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox3.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox4.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox4.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox5.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox5.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox6.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox6.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox7.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox7.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox8.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox8.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox9.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox9.Value = Me.lstMyData.Column(0, i - 1)
Me.TextBox10.Value = Me.lstMyData.Column(0, i - 1)
Me.ComboBox10.Value = Me.lstMyData.Column(0, i - 1)
Me.lstMyData.Selected(i - 1) = True
End Sub
Private Sub ToggleButton2_Click()
Dim i As Integer
i = Me.lstMyData.ListIndex
Me.lstMyData.Selected(i) = True
Me.TextBox1.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox1.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox2.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox2.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox3.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox3.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox4.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox4.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox5.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox5.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox6.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox6.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox7.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox7.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox8.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox8.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox9.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox9.Value = Me.lstMyData.Column(0, i + 1)
Me.TextBox10.Value = Me.lstMyData.Column(0, i + 1)
Me.ComboBox10.Value = Me.lstMyData.Column(0, i + 1)
Me.lstMyData.Selected(i + 1) = True
End Sub
Private Sub UserForm_Initialize()
Dim x As Integer
For x = 0 To Me.lstMyData.ListCount - 1
If Me.lstMyData.Selected(c) Then Me.lstMyData.Selected(x) = False
Next x
End Sub
Private Sub cmdUpdate_Click()
Dim rowslect As Double
Dim i As Integer
Dim wb As Workbook
Dim ws As Worksheet
Set ws = Worksheets("Sheet3")
i = Me.lstMyData.ListIndex
rowselect = i + 1
With ws
.Cells((i + 2), 1).Value = Me.TextBox1.Value
.Cells((i + 2), 2).Value = Me.TextBox2.Value
.Cells((i + 2), 3).Value = Me.TextBox3.Value
.Cells((i + 2), 4).Value = Me.TextBox4.Value
.Cells((i + 2), 5).Value = Me.TextBox5.Value
.Cells((i + 2), 6).Value = Me.TextBox6.Value
.Cells((i + 2), 7).Value = Me.TextBox7.Value
.Cells((i + 2), 8).Value = Me.TextBox8.Value
.Cells((i + 2), 9).Value = Me.TextBox9.Value
.Cells((i + 2), 10).Value = Me.TextBox9.Value
End With
End Sub