+ Reply to Thread
Results 1 to 4 of 4

populate listbox based on selection in previous listbox

  1. #1
    Registered User
    Join Date
    10-28-2007
    Posts
    6

    populate listbox based on selection in previous listbox

    Hi,
    I'm trying to populate a listbox based on the selection i made in the previous listbox,
    e.g. I'm selecting country in listbox1,
    state in listbox 2
    i want hotel names in listbox 3 to populate according to the states i've selected in listbox 2.
    i've used this code to do it so far-using dynamic named ranges, but im wondering if there is another way to do it?

    Please Login or Register  to view this content.

    the code currently only works when the item in the listbox is clicked on, wondering if i can change the code such that if an item is ADDED to a particular listbox, the list for this item will automatically populate in the next listbox

    thanks !!
    Last edited by VBA Noob; 10-28-2007 at 10:44 AM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Welcome to the forum.

    Please read forum rules below. I've wrapped your code for you this time

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    How would the values be getting added to the listbox?

    And how would the ranges associated with those values be named, if they are named at all?

    By the way have you considered using a multicolumn listbox.

    One column displaying the full name of the state and one (hidden) with the named range for that state.

    Then you could dispense with the Select Case strucuture.

  4. #4
    Registered User
    Join Date
    10-28-2007
    Posts
    6
    Hi,

    Thanks for the quick reply!
    I'm new to vb programming so I've not tried a multicolumn listbox -

    how can i write the code to populate such a listbox?

    i've named my ranges in another sheets using the =offset() method,
    so the ranges are named (eg my for malaysia) that when the first listbox item malaysia is selected - it will call the range my .

    just wondering if i can incorporate vlookup / lookup/ index/match into this ?
    cos i have a database of hotels sorted by location, wondering if there's a way to write a code such that it populates according to the selected item in the first listbox, rather than me naming all the ranges

+ 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