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

I want to set the RowSource for a ListBox I have on a UserForm, to the range
A2:A20 on the worksheet named Storage Locations (this worksheet is in the
same workbook). I have been unsuccessful. Any help would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Set RowSource for ListBox

In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Set RowSource for ListBox

I tried entering:

Storage Locations'!$A$2:$A$20

The error I get is Invalid Property value. I am doing this in the
properties area of the ListBox.



"dan dungan" wrote in message
...
In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Set RowSource for ListBox

Try removing the space in your sheet name

StorageLocations!a2:A20
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Set RowSource for ListBox

You missed a leading apostrophe--or was that a typo in the post?

'Storage Locations'!$A$2:$A$20

And you're sure you have a sheet named "Storage Locations"?

"Patrick C. Simonds" wrote:

I tried entering:

Storage Locations'!$A$2:$A$20

The error I get is Invalid Property value. I am doing this in the
properties area of the ListBox.

"dan dungan" wrote in message
...
In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Set RowSource for ListBox

something like this should work:

Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rng As Range
Set ws = Worksheets("Storage Locations")
Set rng = ws.Range("A1:a15")

Me.ListBox1.RowSource = rng.Address

End Sub

--


Gary


"Patrick C. Simonds" wrote in message
...
I tried entering:

Storage Locations'!$A$2:$A$20

The error I get is Invalid Property value. I am doing this in the properties
area of the ListBox.



"dan dungan" wrote in message
...
In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?




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

I'd use:

Me.ListBox1.RowSource = rng.Address(external:=true)

Just to make sure it was using the range from the correct sheet.

Gary Keramidas wrote:

something like this should work:

Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rng As Range
Set ws = Worksheets("Storage Locations")
Set rng = ws.Range("A1:a15")

Me.ListBox1.RowSource = rng.Address

End Sub

--

Gary

"Patrick C. Simonds" wrote in message
...
I tried entering:

Storage Locations'!$A$2:$A$20

The error I get is Invalid Property value. I am doing this in the properties
area of the ListBox.



"dan dungan" wrote in message
...
In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?



--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Set RowSource for ListBox

good point, dave.

--

Gary
Excel 2003


"Dave Peterson" wrote in message
...
I'd use:

Me.ListBox1.RowSource = rng.Address(external:=true)

Just to make sure it was using the range from the correct sheet.

Gary Keramidas wrote:

something like this should work:

Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rng As Range
Set ws = Worksheets("Storage Locations")
Set rng = ws.Range("A1:a15")

Me.ListBox1.RowSource = rng.Address

End Sub

--

Gary

"Patrick C. Simonds" wrote in message
...
I tried entering:

Storage Locations'!$A$2:$A$20

The error I get is Invalid Property value. I am doing this in the
properties
area of the ListBox.



"dan dungan" wrote in message
...
In Excel 2000, I just typed a2:a20 in the listbox properties
rowsource.

What have you tried?
How did it fail?


--

Dave Peterson


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Set RowSource for ListBox

I found this from Tom Ogilvy in 2002:

With userform1
..Rowsource = Worksheets(1).Range("A1"). _
CurrentRegion.Resize(,3).Address(0,0,xlA1,True)
End With

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Set RowSource for ListBox

Hi,

you could save yourself a lot of headaches if you just range name the data
source. Select the range A1:A20 or where ever the items are, and type a name
into the Name Box and press Enter. Suppose you named the range myList then
the row source line of the list/combo box would read myList. Range names
don't allow spaces.

Result: No quotes needed, no spreadsheet references needed, shorter name
less likely to produce a typo. And of course you can use the name in code if
you choose.
Range("myList").Select or [myList].Select for example.

--
Thanks,
Shane Devenshire


"Patrick C. Simonds" wrote:

I want to set the RowSource for a ListBox I have on a UserForm, to the range
A2:A20 on the worksheet named Storage Locations (this worksheet is in the
same workbook). I have been unsuccessful. Any help would be appreciated.




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
XLA and Listbox.rowsource Sven[_8_] Excel Programming 2 May 21st 07 09:54 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 05:48 PM.

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"