Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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) j=1 On Error Resume Next For i = 1 To Packcount If Sheet10.Cells(i, 1) = cbstate.Value Then data(j, 1) = PackagesAvailable.Cells(i, 2).Value data(j, 2) = PackagesAvailable.Cells(i, 3).Value j=j+1 End If Next i ListBox1.ColumnCount = 2 ListBox1.list = data End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "jpendegraft " wrote in message ... Tom solved one issue...using a variable in the array...but I still need to eliminate the blank lines that this generates... I want it to ONLY add lines the satisfy the conditions of the IF statement. currently it will add a line with NO DATA if the statement 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 Sub --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See answer provided in original thread.
-- Regards, Tom Ogilvy "jpendegraft " wrote in message ... Tom solved one issue...using a variable in the array...but I still need to eliminate the blank lines that this generates... I want it to ONLY add lines the satisfy the conditions of the IF statement. currently it will add a line with NO DATA if the statement 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 Sub --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure all the blanks aren't at the bottom of the dropdown? Perhaps that is
acceptable. -- Regards, Tom Ogilvy "jpendegraft " wrote in message ... Thanks Bob!! That did the trick. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Eliminating blanks | Excel Worksheet Functions | |||
Adding items to columns in a listbox | Excel Discussion (Misc queries) | |||
Adding Items to ListBox-eliminating Blanks | Excel Programming | |||
Adding Items to a LISTBOX--eliminating Blank Lines | Excel Programming | |||
Adding items to a spreadsheet from a user form listbox | Excel Programming |