J
jpendegraft
Will post again as I do not see my post.
The Situation: I need to add items (mulitcolumn) to a listbox based o
the value of another combobox. Basically, the user will select th
state, and then based on the state--the listbox will populate.
The problem is 2 fold- first-I can get the items to add, but it als
adds blank lines. I do not want the blank lines-It basically adds
blank line if the value does not match or adds the data if it does.
The second part is that I have to use a constant ("66") rather than
variable ("PackCount") due to the way I structured the code. I'd lik
to use the variable of PACKCOUNT rather than 66 to determine the numbe
of loops for flexability.
Any help would be greatly appreciated.
My code is as follows:
Sub PopulateBox()
Set PackagesAvailable = ThisWorkbook.Sheets("BrandCount")
Packcount
Application.WorksheetFunction.CountA(PackagesAvailable.Range("A:A"))
Dim i As Integer
ListBox1.Clear
Dim Data(1 To 66, 1 To 2)
On Error Resume Next
For i = 1 To 66
If Sheet10.Cells(i, 1) = cbState.Value Then
Data(i, 1) = PackagesAvailable.Cells(i, 2).Value
End If
Next i
For i = 1 To 66
If Sheet10.Cells(i, 1) = cbState.Value Then
Data(i, 2) = PackagesAvailable.Cells(i, 3).Value
End If
Next i
ListBox1.ColumnCount = 2
ListBox1.list = Data
End Su
The Situation: I need to add items (mulitcolumn) to a listbox based o
the value of another combobox. Basically, the user will select th
state, and then based on the state--the listbox will populate.
The problem is 2 fold- first-I can get the items to add, but it als
adds blank lines. I do not want the blank lines-It basically adds
blank line if the value does not match or adds the data if it does.
The second part is that I have to use a constant ("66") rather than
variable ("PackCount") due to the way I structured the code. I'd lik
to use the variable of PACKCOUNT rather than 66 to determine the numbe
of loops for flexability.
Any help would be greatly appreciated.
My code is as follows:
Sub PopulateBox()
Set PackagesAvailable = ThisWorkbook.Sheets("BrandCount")
Packcount
Application.WorksheetFunction.CountA(PackagesAvailable.Range("A:A"))
Dim i As Integer
ListBox1.Clear
Dim Data(1 To 66, 1 To 2)
On Error Resume Next
For i = 1 To 66
If Sheet10.Cells(i, 1) = cbState.Value Then
Data(i, 1) = PackagesAvailable.Cells(i, 2).Value
End If
Next i
For i = 1 To 66
If Sheet10.Cells(i, 1) = cbState.Value Then
Data(i, 2) = PackagesAvailable.Cells(i, 3).Value
End If
Next i
ListBox1.ColumnCount = 2
ListBox1.list = Data
End Su