Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Select Dynamic list for rowsource on a list box

I have a form which is getting values in a list box from a range on a sheet
called Customer. THe length of that list can vary depending on other
selections, it may be from A5 to A500 or A5 to A120. How can I set up the
rowsource to automatically adjust tothe correct range. (it will always start
in Cell A5


thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Select Dynamic list for rowsource on a list box

try something like this:

Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim lastrow As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

With Me.ListBox1
.RowSource = ws.Range("A5:A" & lastrow).Address
End With
End Sub


--


Gary

"Nigel" wrote in message
...
I have a form which is getting values in a list box from a range on a sheet
called Customer. THe length of that list can vary depending on other
selections, it may be from A5 to A500 or A5 to A120. How can I set up the
rowsource to automatically adjust tothe correct range. (it will always start
in Cell A5


thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Select Dynamic list for rowsource on a list box

PERHAPS

you could do the dynamic part on the list name.

instertnameDefine Place this formula on the source
=offset( A5,0,0,conta(A:A),1)

A5 = your starting Cell
conta(A:A) = number of rows that have values "remenber to not have any
empty spaces on this column"
1= width "you could do a conta here as well"





"Gary Keramidas" wrote:

try something like this:

Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim lastrow As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

With Me.ListBox1
.RowSource = ws.Range("A5:A" & lastrow).Address
End With
End Sub


--


Gary

"Nigel" wrote in message
...
I have a form which is getting values in a list box from a range on a sheet
called Customer. THe length of that list can vary depending on other
selections, it may be from A5 to A500 or A5 to A120. How can I set up the
rowsource to automatically adjust tothe correct range. (it will always start
in Cell A5


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
Changing named Validation list to Dynamic list. GlenC Excel Discussion (Misc queries) 1 July 20th 06 11:49 PM
select last cell in a dynamic list using a macro uncrox Excel Discussion (Misc queries) 4 July 19th 06 01:27 PM
How to add different column to a list box using rowsource shirley_kee Excel Discussion (Misc queries) 2 June 29th 06 06:53 AM
How do I set the rowsource for a ComboBox for a dynamic list? ndm berry[_2_] Excel Programming 4 September 29th 05 01:11 PM
Filtered List as Listbox RowSource Ken McLennan[_3_] Excel Programming 9 September 21st 05 12:23 AM


All times are GMT +1. The time now is 04:40 PM.

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"