JohnnyBQue
New Member
- Joined
- Apr 25, 2016
- Messages
- 8
I know I’m overlooking something but can’t get my combo box selection to populate my list box…
Also while your taking a look…how can I replace the “Array” section of the line below
With code that would allow me to choose anything entry I may put under Sheet 1, column “C” and populate the list box with the associated row data?
“Me.comboBox1.list = Array(“Copper”, “Brass”) (Copper & Brass come from Sheet 1 column “C” those are the only two entries at this time in the column)
I use a simple 5 column data range (A-E) about 100 rows deep with headings; the form has 1 label, 1 combobox, 2 command buttons (only 1 used at this time) and 1 listbox
haven't posted here in a while not sure if an excel file cam be uploaded
//
Private Sub ComboBox1_Change()
Me.ListBox1.Clear
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(0, x) = Sheet1.Cells(1, x + 1)
Next x
Me.ListBox1.Selected(0) = True
For i = 1 To Sheet1.Range("A1000000").End(xlUp).Row
If Sheet1.Cells(1, "C") = Me.ComboBox1 Then
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(ListBox1.ListCount - 1, x) = Sheet1.Cells(i, x + 1)
Next x
End If
Next i
End Sub
Private Sub CommandButton2_Click()
Call UserForm_Initialize
End Sub
Private Sub UserForm_Initialize()
Me.Label8.Caption = Date
Me.ComboBox1.List = Array("Copper", "Brass")
For i = 1 To Sheet1.Range("A1000000").End(xlUp).Row
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(i - 1, x) = Sheet1.Cells(i, x + 1)
Next x
Next i
Me.ListBox1.Selected(0) = True
End Sub
Also while your taking a look…how can I replace the “Array” section of the line below
With code that would allow me to choose anything entry I may put under Sheet 1, column “C” and populate the list box with the associated row data?
“Me.comboBox1.list = Array(“Copper”, “Brass”) (Copper & Brass come from Sheet 1 column “C” those are the only two entries at this time in the column)
I use a simple 5 column data range (A-E) about 100 rows deep with headings; the form has 1 label, 1 combobox, 2 command buttons (only 1 used at this time) and 1 listbox
haven't posted here in a while not sure if an excel file cam be uploaded
//
Private Sub ComboBox1_Change()
Me.ListBox1.Clear
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(0, x) = Sheet1.Cells(1, x + 1)
Next x
Me.ListBox1.Selected(0) = True
For i = 1 To Sheet1.Range("A1000000").End(xlUp).Row
If Sheet1.Cells(1, "C") = Me.ComboBox1 Then
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(ListBox1.ListCount - 1, x) = Sheet1.Cells(i, x + 1)
Next x
End If
Next i
End Sub
Private Sub CommandButton2_Click()
Call UserForm_Initialize
End Sub
Private Sub UserForm_Initialize()
Me.Label8.Caption = Date
Me.ComboBox1.List = Array("Copper", "Brass")
For i = 1 To Sheet1.Range("A1000000").End(xlUp).Row
Me.ListBox1.AddItem
For x = 0 To 4
Me.ListBox1.List(i - 1, x) = Sheet1.Cells(i, x + 1)
Next x
Next i
Me.ListBox1.Selected(0) = True
End Sub