Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
HI good afternoon, hope you can help me please, i am trying to copy data from textboxes and comboboxes (15 in total) into a listbox, i have the following code below but i get an error on 'prtBox.ColumnCount =15' please can you help.
VBA Code:
Private Sub CommandButton4_Click()
Dim myarr As Variant, n As Byte
If ComboBox2.Value = Empty Then MsgBox "Please Enter EOD": ComboBox2.SetFocus: Exit Sub
If TextBox1.Value = Empty Then MsgBox "Please Enter MPAN": TextBox1.SetFocus: Exit Sub
If ComboBox3.Value = Empty Then MsgBox "Please Enter Job Category": ComboBox3.SetFocus: Exit Sub
myarr = Array(TextBox10.Value, TextBox1.Value, TextBox2.Value, ComboBox2.Value, TextBox11.Value, TextBox3.Value, ComboBox3.Value, _
ComboBox4.Value, TextBox4.Value, TextBox12.Value, TextBox5.Value, TextBox6.Value, TextBox7.Value, TextBox8.Value, TextBox9.Value)
prtBox.ColumnCount = 15
If prtBox.ListCount <= 0 Then
prtBox.Column = myarr
Else
prtBox.AddItem myarr(0)
For n = 0 To 14
prtBox.List(prtBox.ListCount - 1, n) = myarr(n)
Next n
End If
End Sub