ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating a listbox from range xl2003 (https://www.excelbanter.com/excel-programming/333500-populating-listbox-range-xl2003.html)

Ramthebuffs[_10_]

Populating a listbox from range xl2003
 

I have tried numerous examples on how to populate a listbox from a range
and can't get any of them to work. My only guess is that perhaps it is
something different in excel 2003? Maybe I need to change something in
properties?

I'm using the default ListBox1 on a standard userform(Sub
UserForm1_Initialize) and am trying to get a list from
sheets(customers).range("a1:a30")

Any ideas?


--
Ramthebuffs
------------------------------------------------------------------------
Ramthebuffs's Profile: http://www.excelforum.com/member.php...o&userid=16429
View this thread: http://www.excelforum.com/showthread...hreadid=384141


anilsolipuram[_152_]

Populating a listbox from range xl2003
 

I am assuming the list1 is the name of listbox




Private Sub UserForm_Initialize()

For Each c In Range("a1:a30")
if c.value<"" then
list1.AddItem (c.Value)
end if
Next
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=384141


Ramthebuffs[_11_]

Populating a listbox from range xl2003
 

I just found this one line of code to do the work. I'm not sure what
was wrong with every other method I tried. I kept on getting subscript
out of range error.


UserForm1.ListBox1.RowSource = "Customers!A1:a30"

Thanks for the help though.


--
Ramthebuffs
------------------------------------------------------------------------
Ramthebuffs's Profile: http://www.excelforum.com/member.php...o&userid=16429
View this thread: http://www.excelforum.com/showthread...hreadid=384141


Doug Glancy

Populating a listbox from range xl2003
 
Ramthebuffs,

Don't be coy, give us the details <g. It's hard to say without knowing
what you've tried or what used to work for you. This works for me:

Private Sub UserForm_Initialize()
Me.ListBox1.List = Worksheets("customers").Range("A1:A30").Value
End Sub

hth,

Doug

"Ramthebuffs"
wrote in message
...

I have tried numerous examples on how to populate a listbox from a range
and can't get any of them to work. My only guess is that perhaps it is
something different in excel 2003? Maybe I need to change something in
properties?

I'm using the default ListBox1 on a standard userform(Sub
UserForm1_Initialize) and am trying to get a list from
sheets(customers).range("a1:a30")

Any ideas?


--
Ramthebuffs
------------------------------------------------------------------------
Ramthebuffs's Profile:
http://www.excelforum.com/member.php...o&userid=16429
View this thread: http://www.excelforum.com/showthread...hreadid=384141




OKLover

Populating a listbox from range xl2003
 
But how about multiple-columns? does it still works ?





"Doug Glancy" ...
Ramthebuffs,

Don't be coy, give us the details <g. It's hard to say without knowing
what you've tried or what used to work for you. This works for me:

Private Sub UserForm_Initialize()
Me.ListBox1.List = Worksheets("customers").Range("A1:A30").Value
End Sub

hth,

Doug

"Ramthebuffs"
wrote in message
...

I have tried numerous examples on how to populate a listbox from a range
and can't get any of them to work. My only guess is that perhaps it is
something different in excel 2003? Maybe I need to change something in
properties?

I'm using the default ListBox1 on a standard userform(Sub
UserForm1_Initialize) and am trying to get a list from
sheets(customers).range("a1:a30")

Any ideas?


--
Ramthebuffs
------------------------------------------------------------------------
Ramthebuffs's Profile:
http://www.excelforum.com/member.php...o&userid=16429
View this thread:
http://www.excelforum.com/showthread...hreadid=384141






Ramthebuffs[_12_]

Populating a listbox from range xl2003
 

Doug, that one seemed to work also. I think I'll use it actually, it
looks a little more purdy ;-)

I still don't really know what went wrong. Maybe it was just late and
there was some simple answer to the problems I was having. Anyway, I
much prefer 1 line to more.


--
Ramthebuffs
------------------------------------------------------------------------
Ramthebuffs's Profile: http://www.excelforum.com/member.php...o&userid=16429
View this thread: http://www.excelforum.com/showthread...hreadid=384141



All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com