Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Fill combo box ignoring blanks

I have code to fill a combo box from a selected range, but it also picks up
any blank cells interspersed in that range. Is there a way to tell it to
ignore blanks? This is my code (OpenWS and Lr were declared earlier):

With Me.cboPO
..Clear
ListItems = OpenWS.Range("D7:D600").Value
ListItems = Application.WorksheetFunction.Transpose(ListItems)
' convert values to a vertical array
For i = 1 To Lr
.AddItem ListItems(i) ' populate the listbox
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With

Thanks for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Fill combo box ignoring blanks

With Me.cboPO
..Clear
ListItems = OpenWS.Range("D7:D600").Value


For i = 1 To Ubound(ListItems,1)
if len(trim(listItems(i,1))) 0 then
.AddItem ListItems(i,1) ' populate the listbox
end if
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With

--
Regards,
Tom Ogilvy

"Shannon" wrote:

I have code to fill a combo box from a selected range, but it also picks up
any blank cells interspersed in that range. Is there a way to tell it to
ignore blanks? This is my code (OpenWS and Lr were declared earlier):

With Me.cboPO
.Clear
ListItems = OpenWS.Range("D7:D600").Value
ListItems = Application.WorksheetFunction.Transpose(ListItems)
' convert values to a vertical array
For i = 1 To Lr
.AddItem ListItems(i) ' populate the listbox
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With

Thanks for your help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Fill combo box ignoring blanks

Thank you so much! Works woderfully!

"Tom Ogilvy" wrote:

With Me.cboPO
.Clear
ListItems = OpenWS.Range("D7:D600").Value


For i = 1 To Ubound(ListItems,1)
if len(trim(listItems(i,1))) 0 then
.AddItem ListItems(i,1) ' populate the listbox
end if
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With

--
Regards,
Tom Ogilvy

"Shannon" wrote:

I have code to fill a combo box from a selected range, but it also picks up
any blank cells interspersed in that range. Is there a way to tell it to
ignore blanks? This is my code (OpenWS and Lr were declared earlier):

With Me.cboPO
.Clear
ListItems = OpenWS.Range("D7:D600").Value
ListItems = Application.WorksheetFunction.Transpose(ListItems)
' convert values to a vertical array
For i = 1 To Lr
.AddItem ListItems(i) ' populate the listbox
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With

Thanks for your help!

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
Criteria average ignoring blanks flumpuk Excel Discussion (Misc queries) 5 October 17th 07 11:39 AM
Criteria average ignoring blanks flumpuk Excel Discussion (Misc queries) 1 October 17th 07 11:19 AM
Ignoring blanks from Column(s) Michael Excel Worksheet Functions 3 December 3rd 06 08:58 PM
Ignoring blanks and consolidating stevemyers Excel Discussion (Misc queries) 1 June 28th 06 07:39 PM
Ignoring blanks exsam21 Excel Discussion (Misc queries) 2 January 18th 06 05:19 PM


All times are GMT +1. The time now is 03:39 AM.

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

About Us

"It's about Microsoft Excel"