dss28
Board Regular
- Joined
- Sep 3, 2020
- Messages
- 165
- Office Version
- 2007
- Platform
- Windows
I want to transfer the userform textbox and Combobox data (total more than 15) to listbox.
I am using following code but gives me error " "Run time Error 13- type mismatch" on line :
myArr = Array(TextBox4, TextBox21, TextBox7, TextBox5, TextBox6, TextBox8, TextBox9, TextBox18, TextBox20, TextBox1, TextBox2, ComboBox2, TextBox3, ComboBox1, TextBox12, TextBox14)
please suggest to correct the code
I am using following code but gives me error " "Run time Error 13- type mismatch" on line :
myArr = Array(TextBox4, TextBox21, TextBox7, TextBox5, TextBox6, TextBox8, TextBox9, TextBox18, TextBox20, TextBox1, TextBox2, ComboBox2, TextBox3, ComboBox1, TextBox12, TextBox14)
please suggest to correct the code
VBA Code:
Private Sub Commandbutton1_Click() 'trasnfer data from all textboxes to listbox
Dim myArr() As Long
Dim n As Long
myArr = Array(TextBox4, TextBox21, TextBox7, TextBox5, TextBox6, TextBox8, TextBox9, TextBox18, TextBox20, TextBox1, TextBox2, ComboBox2, TextBox3, ComboBox1, TextBox12, TextBox14)
For n = 0 To 15 ' 16 columns required to be added to listbox
UserForm3.ListBox1.AddItem myArr(n), UserForm3.ListBox1.ListCount
Next n
'clear form for another line item
UserForm3.TextBox4 = ""
UserForm3.TextBox21 = ""
UserForm3.TextBox7 = ""
UserForm3.TextBox5 = ""
UserForm3.TextBox6 = ""
UserForm3.TextBox8 = ""
UserForm3.TextBox9 = ""
UserForm3.ComboBox1 = ""
UserForm3.TextBox12 = ""
UserForm3.TextBox14 = ""
End Sub