Copy data from textbox and Combobox into Listbox

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. 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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
I hope you can help me with this please?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top