I have a worksheet ("Breakdown") that consists of a table ("breakdownTable"). I have a button that opens a userform called "SearchForm" that displays a listbox. So far I have it so when I double click a selected item from this list box a second userform called "EditForm" displays that automatically inputs the details of the selected item into multiple textboxes.
I'm having trouble with getting the update button in the Editform to update both the listbox and the worksheet table. I've managed to get it to update the listbox but it won't do the same for the table.
This is what I have for the SearchForm Code:
And this is what I have for the EditForm:
I'm quite new to excel vba so any assistance is appreciated. I've tried to follow tutorials and looked at other forums but I'm just not quite understanding. I know it's something to do with the Set DBS and the rest below it in the EditForm code. The error I get is '1004' - Application-defined or object-defined error.
I'm having trouble with getting the update button in the Editform to update both the listbox and the worksheet table. I've managed to get it to update the listbox but it won't do the same for the table.
This is what I have for the SearchForm Code:
VBA Code:
Private Sub playerList_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With EditForm
.TextBox1.text = Me.playerList.Column(1)
.TextBox2.text = Me.playerList.Column(0)
.TextBox3.text = Me.playerList.Column(2)
.TextBox4.text = Me.playerList.Column(3)
.TextBox5.text = Me.playerList.Column(4)
.TextBox6.text = Me.playerList.Column(6)
.TextBox7.text = Me.playerList.Column(7)
End With
EditForm.Show
End Sub
Private Sub UserForm_Initialize()
playerList.List = Worksheets("Breakdown").ListObjects("breakdownTable").DataBodyRange.Value2
playerList.ColumnCount = 9
playerList.ColumnHeads = False
End Sub
And this is what I have for the EditForm:
Code:
Private Sub CommandButton1_Click()
Dim DBS As Range
Dim IND, X As Integer
Set wso = ThisWorkbook.Worksheets("Breakdown")
With SearchForm.playerList
.Column(1) = Me.TextBox1.text
.Column(0) = Me.TextBox2.text
.Column(2) = Me.TextBox3.text
.Column(3) = Me.TextBox4.text
.Column(4) = Me.TextBox5.text
.Column(6) = Me.TextBox6.text
.Column(7) = Me.TextBox7.text
Set DBS = wso.ListObjects("breakdownTable").DataBodyRange.End(x1Up)
For X = 1 To 9
DBS.Offset(1, X - 1) = .Column(X - 1)
IND = .ListIndex + 1
wso.Cells(IND, X) = .Column(X - 1)
Next X
Unload Me
End With
End Sub
I'm quite new to excel vba so any assistance is appreciated. I've tried to follow tutorials and looked at other forums but I'm just not quite understanding. I know it's something to do with the Set DBS and the rest below it in the EditForm code. The error I get is '1004' - Application-defined or object-defined error.