Hello guys,
I have two listboxes, listbox1 and listbox2. In the first listbox the values have 3 columns with values are initial loaded. Then the user need to select items and then all values from the 3 columns need to be transferred to the other listbox2.
When I try to select the items, I'm always getting the error message: Object required...Error code 424
My code is here:
Option Explicit
Private Sub SelectItems_btn_Click()
Dim SelectedItems As String
Dim i As Integer
Dim ListBox2i As Integer
ListBox2i = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Me.ListBox2.AddItem
Me.ListBox2.List(ListBox2i, 0) = ListBox1.List(i, 0).Value
Me.ListBox2.List(ListBox2i, 1) = ListBox1.List(i, 1).Value
Me.ListBox2.List(ListBox2i, 2) = ListBox1.List(i, 2).Value
ListBox2i = ListBox2i + 1
End If
Next
End Sub
Private Sub UserForm_Initialize()
ListBox1.MultiSelect = 2
ListBox2.MultiSelect = 2
Dim RowsNumber As Integer
Dim RowsNumberOnly As Integer
Dim i As Integer
Dim Customers As Long
Dim customersloop As Long
Dim test As String
RowsNumber = FunctionCount.calculateRows
RowsNumberOnly = FunctionCount.calculateRowsValue
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "50;50;50"
ListBox2.ColumnCount = 3
ListBox2.ColumnWidths = "50;50;50"
Customers = 10
i = 0
For customersloop = Customers To RowsNumber
ListBox1.AddItem
ListBox1.List(i, 0) = Sheets("Test").Range("J" & customersloop).Value
ListBox1.List(i, 1) = Sheets("Test").Range("K" & customersloop).Value
ListBox1.List(i, 2) = Sheets("Test").Range("L" & customersloop).Value
i = i + 1
Next
End Sub
Best regards and thanks in advance!
Matthias
I have two listboxes, listbox1 and listbox2. In the first listbox the values have 3 columns with values are initial loaded. Then the user need to select items and then all values from the 3 columns need to be transferred to the other listbox2.
When I try to select the items, I'm always getting the error message: Object required...Error code 424
My code is here:
Option Explicit
Private Sub SelectItems_btn_Click()
Dim SelectedItems As String
Dim i As Integer
Dim ListBox2i As Integer
ListBox2i = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Me.ListBox2.AddItem
Me.ListBox2.List(ListBox2i, 0) = ListBox1.List(i, 0).Value
Me.ListBox2.List(ListBox2i, 1) = ListBox1.List(i, 1).Value
Me.ListBox2.List(ListBox2i, 2) = ListBox1.List(i, 2).Value
ListBox2i = ListBox2i + 1
End If
Next
End Sub
Private Sub UserForm_Initialize()
ListBox1.MultiSelect = 2
ListBox2.MultiSelect = 2
Dim RowsNumber As Integer
Dim RowsNumberOnly As Integer
Dim i As Integer
Dim Customers As Long
Dim customersloop As Long
Dim test As String
RowsNumber = FunctionCount.calculateRows
RowsNumberOnly = FunctionCount.calculateRowsValue
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "50;50;50"
ListBox2.ColumnCount = 3
ListBox2.ColumnWidths = "50;50;50"
Customers = 10
i = 0
For customersloop = Customers To RowsNumber
ListBox1.AddItem
ListBox1.List(i, 0) = Sheets("Test").Range("J" & customersloop).Value
ListBox1.List(i, 1) = Sheets("Test").Range("K" & customersloop).Value
ListBox1.List(i, 2) = Sheets("Test").Range("L" & customersloop).Value
i = i + 1
Next
End Sub
Best regards and thanks in advance!
Matthias