I have a userform in Excel which has a listbox which pulls data from a dynamic range (5 columns, 1 being a unique ID number).
When the user clicks the record it displays each value in a text box and the ID number in a label.
Private Sub ListBox1_Click()
Me.Label6 = Me.ListBox1.List(ListBox1.ListIndex, 0) 'record number
Me.TextBox1 = Me.ListBox1.List(ListBox1.ListIndex, 4)'Staff name
Me.TextBox2 = Me.ListBox1.List(ListBox1.ListIndex, 1)'Strategy
Me.TextBox3 = Me.ListBox1.List(ListBox1.ListIndex, 2)'Notes
Me.TextBox4 = Me.ListBox1.List(ListBox1.ListIndex, 3)'Date
End Sub
I want the user to makes changes to the record and update the list box and data on sheet. It is updating the right record just with one value!
User form with updated same value in all columns see rec# 5
Private Sub CMDUpdate_Click()
Dim erowa As Integer
Dim x As Integer
erowa = Application.WorksheetFunction.CountA(Sheet9.Range("A:A"))
For x = 2 To erowa
If Sheet9.Cells(x, "A").Value = Me.Label6 Then 'this is the unique ID
Sheet9.Cells(x, "B").Value = Me.TextBox1.Value 'Staff name
Sheet9.Cells(x, "C").Value = Me.TextBox2.Value 'Strategy
Sheet9.Cells(x, "D").Value = Me.TextBox3.Value 'Notes
Sheet9.Cells(x, "E").Value = Me.TextBox4.Value 'date
End If
Next
End Sub
Also date format for some reason displays the Julian value!
I spent a whole day researching, watching tutorials, reading blogs.