Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ListBox RowSource Property

I'd like to populate my listbox with values from cells b1:f1. If I put the
following entry into the RowSource property, I only get the value in b1 to
populate my listbox:

sheet1!b1:f1

I've noticed that if the values in the worksheet run down a column instead
of across a row, I get what I want. Thus, RowSource property works with this
entry:

sheet1!a2:a6

Sadly, I need to be able to populate my listbox from cells across a row and
not down a column. Can I adjust my value in the RowSource property to give me
what I want? If not, is there another way to do this? An example would be
nice.

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default ListBox RowSource Property

Hi

You can populate the ListBox when the userform is initialized, just remember
to delete what you have in the RowSource property now.

Private Sub UserForm_Initialize()
Set SourceRange = Worksheets("Sheet1").Range("B1:F1")
For Each cell In SourceRange
Me.ListBox1.AddItem cell.Value
Next
End Sub

Regards,
Per

"flashrabbit" skrev i meddelelsen
...
I'd like to populate my listbox with values from cells b1:f1. If I put the
following entry into the RowSource property, I only get the value in b1 to
populate my listbox:

sheet1!b1:f1

I've noticed that if the values in the worksheet run down a column instead
of across a row, I get what I want. Thus, RowSource property works with
this
entry:

sheet1!a2:a6

Sadly, I need to be able to populate my listbox from cells across a row
and
not down a column. Can I adjust my value in the RowSource property to give
me
what I want? If not, is there another way to do this? An example would be
nice.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ListBox RowSource Property

You could create a new sheet (hide it???)
and put that data in a vertical list and use that
(maybe even use formulas if the headers can change)

Or you can add the entries via code.

In the userform_initialize event:

dim myCell as range
for each mycell in worksheets("Somesheetname").range("b1:f1").cells
me.listbox.additem mycell.value 'mycell.text????
next mycell




flashrabbit wrote:

I'd like to populate my listbox with values from cells b1:f1. If I put the
following entry into the RowSource property, I only get the value in b1 to
populate my listbox:

sheet1!b1:f1

I've noticed that if the values in the worksheet run down a column instead
of across a row, I get what I want. Thus, RowSource property works with this
entry:

sheet1!a2:a6

Sadly, I need to be able to populate my listbox from cells across a row and
not down a column. Can I adjust my value in the RowSource property to give me
what I want? If not, is there another way to do this? An example would be
nice.

Thanks!


--

Dave Peterson
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 getting error 380 cannot set the rowsource property cellist Excel Programming 2 September 3rd 09 05:58 PM
RowSource in Property Dialog Toppers Excel Programming 0 March 26th 06 11:47 PM
Rowsource Property Mohan Excel Programming 2 February 14th 05 07:41 PM
Could not set the RowSource property Tom Ogilvy Excel Programming 0 August 17th 04 07:48 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


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