Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Adding Items to a ListBox-Eliminating Blanks-Part II

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding Items to a ListBox-Eliminating Blanks-Part II

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding Items to a ListBox-Eliminating Blanks-Part II

Thanks Bob!! That did the trick

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding Items to a ListBox-Eliminating Blanks-Part II

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminating blanks LiAD Excel Worksheet Functions 5 July 8th 09 06:01 PM
Adding items to columns in a listbox Daniel Bonallack Excel Discussion (Misc queries) 1 May 7th 07 04:45 PM
Adding Items to ListBox-eliminating Blanks jpendegraft[_9_] Excel Programming 10 July 16th 04 02:25 AM
Adding Items to a LISTBOX--eliminating Blank Lines jpendegraft[_8_] Excel Programming 2 May 1st 04 03:18 PM
Adding items to a spreadsheet from a user form listbox aet-inc[_4_] Excel Programming 1 December 3rd 03 05:13 AM


All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"