View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jpendegraft[_11_] jpendegraft[_11_] is offline
external usenet poster
 
Posts: 1
Default Adding Items to a ListBox-Eliminating Blanks-Part II

Tom solved one issue...using a variable in the array...but I still nee
to eliminate the blank lines that this generates...

I want it to ONLY add lines the satisfy the conditions of the I
statement. currently it will add a line with NO DATA if the statemen
is false..

Sub PopulateBox()

Dim data()

Set PackagesAvailable = ThisWorkbook.Sheets("BrandCount")
Packcount
Application.WorksheetFunction.CountA(PackagesAvail able.Range("A:A"))
Dim i As Integer

ListBox1.Clear

ReDim data(1 To Packcount, 1 To 2)

On Error Resume Next
For i = 1 To Packcount
If Sheet10.Cells(i, 1) = cbstate.Value Then
data(i, 1) = PackagesAvailable.Cells(i, 2).Value
data(i, 2) = PackagesAvailable.Cells(i, 3).Value
End If
Next i

ListBox1.ColumnCount = 2

ListBox1.list = data

End Su

--
Message posted from http://www.ExcelForum.com