Sorry for not getting back sooner - think I missed your last post.
Anyway, the listbox on your userform has 3 columns, in this code you are trying to refer to columns 4, 5 and 6 of the listbox.
Private Sub ListBox1_Click()
'populates combo and text box with index values to allow user to edit.
cbTextBox1.Text = Me.ListBox1.List(ListBox1.ListIndex, 3)
txtTextBox2.Text = Me.ListBox1.List(ListBox1.ListIndex, 4)
txtTextBox3.Text = Me.ListBox1.List(ListBox1.ListIndex, 5)
End Sub
Try changing it to this.
Private Sub ListBox1_Click()
'populates combo and text box with index values to allow user to edit.
cbTextBox1.Text = Me.ListBox1.List(ListBox1.ListIndex, 0)
txtTextBox2.Text = Me.ListBox1.List(ListBox1.ListIndex, 1)
txtTextBox3.Text = Me.ListBox1.List(ListBox1.ListIndex, 2)
End Sub
That will fix that error but unfortunately brings up another error here.
Private Sub cbTextBox1_Change()
Dim LastRow As Long
Dim LastCol As Long
Dim res As Variant
On Error Resume Next
'change MD and TVD values when user selects formation value from dropdown list
With Sheets(msSHEET_NAME)
res = Application.Index(Range(Cells(2, LastCol), Cells(LastRow, 1)), _
Application.Match(cbTextBox1.Value, Range("D:F"), 0), 2)
txtTextBox2.Value = res
txtTextBox3.Value = res
End With
End Sub
In this code LastCol is never given a value so Cells(2,LastCol) will fail.
What is it you are trying to do here?
Bookmarks