+ Reply to Thread
Results 1 to 6 of 6

Populating a listbox from range xl2003

  1. #1
    Registered User
    Join Date
    11-13-2004
    Posts
    49

    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?

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451

    Arrow

    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

  3. #3
    Registered User
    Join Date
    11-13-2004
    Posts
    49
    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.

  4. #4
    Doug Glancy
    Guest

    Re: 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" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > 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
    >




  5. #5
    OKLover
    Guest

    Re: Populating a listbox from range xl2003

    But how about multiple-columns? does it still works ?





    "Doug Glancy" <[email protected]> 写入消息新闻:[email protected]...
    > 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" <[email protected]>
    > wrote in message
    > news:[email protected]...
    >>
    >> 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
    >>

    >
    >




  6. #6
    Registered User
    Join Date
    11-13-2004
    Posts
    49
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1