Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default eliminate blanks from listbox rowsource

I am successfully updating the contents of a listbox using the
selection of a combobox. the listbox is populated by means of setting
the rowsource to a named range when the combobox is changed.
unfortunately, the named ranges will sometimes have blanks which I do
not want displayed in the listbox. my current code looks like this:

Private Sub ComboBoxgroupHSS_DropButtonClick()
With UserFormDesign
.ListBoxHSS.RowSource = .ComboBoxgroupHSS.Value
End With
End Sub

Is there a way to eliminate these blanks without altering my code too
much?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default eliminate blanks from listbox rowsource

Rather than assign the named range to the rowsource property, run a loop
against the named range and test for blank / empty cells, then add non-empty
cells into the list control. Also use the comboxbox change event. Not
shown but you should check that the range chosen is valid?


Private Sub ComboBoxgroupHSS_Change()
Dim c As Range
With UserFormDesign
.ListBoxHSS.Clear
For Each c In Range(.ComboBoxgroupHSS.Value)
If Len(Trim(c.Value)) 0 Then .ListBoxHSS.AddItem c.Value
Next
End With
End Sub


--
Cheers
Nigel



"Jacob" wrote in message
ps.com...
I am successfully updating the contents of a listbox using the
selection of a combobox. the listbox is populated by means of setting
the rowsource to a named range when the combobox is changed.
unfortunately, the named ranges will sometimes have blanks which I do
not want displayed in the listbox. my current code looks like this:

Private Sub ComboBoxgroupHSS_DropButtonClick()
With UserFormDesign
.ListBoxHSS.RowSource = .ComboBoxgroupHSS.Value
End With
End Sub

Is there a way to eliminate these blanks without altering my code too
much?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default eliminate blanks from listbox rowsource

thanks
This makes sense, but I keep getting an error where I have .ListBoxHSS
and I'm not sure why?


On Nov 1, 11:43 am, "Nigel" wrote:
Rather than assign the named range to the rowsource property, run a loop
against the named range and test for blank / empty cells, then add non-empty
cells into the list control. Also use the comboxbox change event. Not
shown but you should check that the range chosen is valid?

Private Sub ComboBoxgroupHSS_Change()
Dim c As Range
With UserFormDesign
.ListBoxHSS.Clear
For Each c In Range(.ComboBoxgroupHSS.Value)
If Len(Trim(c.Value)) 0 Then .ListBoxHSS.AddItem c.Value
Next
End With
End Sub

--
Cheers
Nigel

"Jacob" wrote in glegroups.com...

I am successfully updating the contents of a listbox using the
selection of a combobox. the listbox is populated by means of setting
the rowsource to a named range when the combobox is changed.
unfortunately, the named ranges will sometimes have blanks which I do
not want displayed in the listbox. my current code looks like this:


Private Sub ComboBoxgroupHSS_DropButtonClick()
With UserFormDesign
.ListBoxHSS.RowSource = .ComboBoxgroupHSS.Value
End With
End Sub


Is there a way to eliminate these blanks without altering my code too
much?


Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default eliminate blanks from listbox rowsource

I figured out my problem but ran into another. I had to remove the
rowsource that was specified for the listbox. but now I have a problem
because my range was two columns. it is now treating it as one column.



On Nov 1, 12:24 pm, "Jacob" wrote:
thanks
This makes sense, but I keep getting an error where I have .ListBoxHSS
and I'm not sure why?

On Nov 1, 11:43 am, "Nigel" wrote:

Rather than assign the named range to the rowsource property, run a loop
against the named range and test for blank / empty cells, then add non-empty
cells into the list control. Also use the comboxbox change event. Not
shown but you should check that the range chosen is valid?


Private Sub ComboBoxgroupHSS_Change()
Dim c As Range
With UserFormDesign
.ListBoxHSS.Clear
For Each c In Range(.ComboBoxgroupHSS.Value)
If Len(Trim(c.Value)) 0 Then .ListBoxHSS.AddItem c.Value
Next
End With
End Sub


--
Cheers
Nigel


"Jacob" wrote in glegroups.com...


I am successfully updating the contents of a listbox using the
selection of a combobox. the listbox is populated by means of setting
the rowsource to a named range when the combobox is changed.
unfortunately, the named ranges will sometimes have blanks which I do
not want displayed in the listbox. my current code looks like this:


Private Sub ComboBoxgroupHSS_DropButtonClick()
With UserFormDesign
.ListBoxHSS.RowSource = .ComboBoxgroupHSS.Value
End With
End Sub


Is there a way to eliminate these blanks without altering my code too
much?


Thanks


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
Listbox - Rowsource Paul W Smith[_4_] Excel Programming 7 February 24th 06 09:22 PM
RowSource in ListBox Noah Excel Programming 2 November 17th 05 02:00 PM
RowSource in ListBox aet-inc[_2_] Excel Programming 1 December 3rd 03 12:41 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
listbox rowsource Christy[_2_] Excel Programming 4 September 20th 03 11:44 PM


All times are GMT +1. The time now is 07:40 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"